The third parameter in AddEventListener is usecapture, a bool type. When False for Bubbling gets (by the inward), true is the capture mode (by the outside).
- <div id="id1" style= "width:200px; height:200px; Position:absolute; top:100px; left:100px; Background-color:blue; Z-index:4 ">
- <div id="Id2" style= "width:200px; height:200px; Position:absolute; top:20px; left:70px; Background-color:green; Z-index:1 "></div>
- </Div>
- document.getelementbyid ( ' Id1 '). AddEventListener ( ' click ', function () { Console.log ( ' id1 ');}, false);
-
- document.getelementbyid ( ' Id2 '). AddEventListener ( ' click ', function () { console.log ( Span class= "string" > ' Id2 ');}, false);
- document.getElementById ('id1 '). AddEventListener (' click ', function () {Console.log (' id1 ');}, FALSE);
- document.getElementById ('id2 '). AddEventListener (' click ', function () {Console.log (' Id2 ');}, FALSE);
When you click a div, the corresponding event is run according to the usecapture parameter.
JS in the AddEventListener in the 3rd parameter