If I trigger an event (say click) on an element. Will it be listen twice by it's parent (because of capture and bobble phase). If yes, isn't it wrong?
Asked
Active
Viewed 29 times
-1

Brian Tompsett - 汤莱恩
- 5,753
- 72
- 57
- 129

Akhilesh Kumar
- 9,085
- 13
- 57
- 95
-
Possible duplicate of [What is event bubbling and capturing?](http://stackoverflow.com/questions/4616694/what-is-event-bubbling-and-capturing) – Matt Burland Dec 15 '15 at 19:02
1 Answers
0
I believe you're asking about event bubbling. It's not wrong, in fact it's there on purpose! The nice thing about bubbling is that you can cancel it at any point. So if something receives an event that it doesn't want to bubble up to its parent, you would just use:e.stopPropagation()
, where e
is your event.

TwoStraws
- 12,862
- 3
- 57
- 71