Why chrome ignores the event handler?

0 like 0 dislike
5 views
In chrome the handler of the parent node intercepts the click and the handler child element are not triggered. FF performs both handlers. If you leave the same two events (only the onmousedown or onclick only), everything works correctly.

HTML
Child 


JS
var child = document.querySelector("#child"); var parent = document.querySelector("#parent"); child.onclick = function(){ alert("hi, I'm Child"); } parent.onmousedown = function(){ alert("hi, I'm Parent"); }


Here is an example on jsfiddle
by | 5 views

2 Answers

0 like 0 dislike
child.addEventListener('click', function(){ alert("hi, I'm Child"); }) child.addEventListener('mousedown', function(){ alert("hi, I'm Parent"); })


To read.
by
0 like 0 dislike
Indeed, it was not working so
Perhaps this is some feature of the ascent events.
You can just check targets, if not zamorachivatsya
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked Apr 24, 2019 by lucifer_jr
0 like 0 dislike
1 answer
asked Mar 25, 2019 by karazyabko
110,608 questions
257,186 answers
0 comments
33,901 users