Can a tag have multiple event attributes at once? | SoloLearn: Learn to code for FREE!

0

Can a tag have multiple event attributes at once?

For example: <button onClick = "calc();" onClick = document.write("Hey there!");>click me</button>

6/2/2020 6:45:49 PM

Xavier K Muneku🇿🇲

2 Answers

New Answer

+2

For multiple events on the same element has to be used element.addEventListener("click", myFunction); element.addEventListener("touchend", clearing); element.addEventListener("click", calc);

+1

Event Listeners The addEventListener() method attaches an event handler to an element without overwriting existing event handlers. You can add many event handlers to one element. You can also add many event handlers of the same type to one element, i.e., two "click" events. https://www.sololearn.com/learn/JavaScript/2758/