0
votes

How do i attach multiple event handlers to addEventListener() method For eg: elem.addEventListener("mouseover",handlers....,false/true); I also wanted to know how the bubbling when set to false and capturing when set to true on the 3rd parameter does in the dom tree.

1

1 Answers

2
votes

Event bubbling means that when an event is triggered on an element, this element's parent is then checked for an event of the same time. If one exists, it is also triggered. This process is then repeated all the way up through the DOM tree. I believe that bubbling events will also make use of capturing (see below) before the bubbling process.

Capturing starts from the root and traverses the DOM tree down to the target element, triggering events of the target's type on the way.

For a better understanding of this, you can find more information here.

As for your first question, it has been a while since I worked with this, so therefore I do not remember a way to do what you want in one statement. However, you could do something like this:

myElement.addEventListener('click', myFunction1, false); myElement.addEventListener('click', myFunction2, false);