Why we need to use stopPropagation in javascript events?

谁说胖子不能爱 提交于 2019-12-12 04:48:49

问题


There are ways of registering Events to objects in an HTML file. So this way an object is set to detect events.

In case we think 2 div elements one inside other; If i attach an onClick event to inner div; this means outer div was not attached one. So it should NOT detect the click event. Why still we need to use stopPropagation () ? since we did not attach any other event detection...

来源:https://stackoverflow.com/questions/43953228/why-we-need-to-use-stoppropagation-in-javascript-events

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!