+ 1

If I click on a div above body element whose click event will be activated?

I have applied click event on both div and body. Whose click event will b activated? Body or div or both?

20th Jan 2017, 2:09 PM
Divesh Agarwal
Divesh Agarwal - avatar
1 Answer
+ 10
First body then div ("bubbling", use "addEventListener(event,callback,true)" to change it to "capturing" and thus reverse priority order
or use "stopPropagation()" to make first event deactivate the second
)

20th Jan 2017, 2:14 PM
Valen.H. ~
Valen.H. ~ - avatar