Answer the question
In order to leave comments, you need to log in
Why is chrome ignoring the event handler?
In chrome, the parent node handler intercepts the click and the child element handler does not fire. FF executes both handlers. If you leave two identical events (onmousedown only or onclick only), everything works correctly.
HTML
<section id = "parent">
<div id = "child">
Child
</div>
</section>
var child = document.querySelector("#child");
var parent = document.querySelector("#parent");
child.onclick = function(){
alert("Привет, я - Child");
}
parent.onmousedown = function(){
alert("Привет, я - Parent");
}
Answer the question
In order to leave comments, you need to log in
child.addEventListener('click', function(){
alert("Привет, я - Child");
})
child.addEventListener('mousedown', function(){
alert("Привет, я - Parent");
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question