How to implement event capture in js
This article mainly introduces how to achieve event capture in js, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.
1. When a mouse clicks or triggers a dom event, the element that triggers the dom event is called the event source.
2. The browser propagates events from the root node = > event source (from outside to inside).
3. The less specific node should receive the event earlier, and the most specific node should receive the event last.
Example
S2 s1.addEventListener ("click", function (e) {console.log ("S1 bubbling event");}, false); s2.addEventListener ("click", function (e) {console.log ("S2 bubbling event");}, false) Thank you for reading this article carefully. I hope the article "how to capture events in js" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!