qypt15
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!