DOM event flow


<div><button></button></div>

btn.addEventListener("click", function(){
    console.log("btn");
},false);

div.addEventListener("click", function(){
    console.log("div");
}, false);
There is no problem with the capture and bubbling of
events in the code

above.


<div onclick = "javascript:console.lg("div")">
    <button></button>
</div>

btn.addEventListener("click", function(){
    console.log("btn");
},false);

< hr >

the code above
div event is always triggered? Why is that?

Mar.13,2021

the following is always triggered because the event in button is bubbling


addEventListener the third parameter to learn about

Menu