The example demonstrates bubbling when adding different event listeners Different from captured.



Click on the paragraph, I am bubble.





Click on the paragraph, I am capturing.



<script><br>function myP(e) {<br> alert("You clicked on the P element!");<br> window.event ? window.event.cancelBubble = true : e.stopPropagation();<br>}<br>function myDiv() {<br> alert("You clicked the DIV element!");<br>}<br>function myPa() {<br> alert("You clicked on the P2 element!");<br>}<br> function myDiva() {<br> alert("You clicked on the DIV2 element!");<br>} <br></script>


The above is the detailed content of Detailed explanation of examples of js stopping bubbling. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Organize the usage of a tagNext article:Organize the usage of a tag

Related articles

See more