I was looking at http://www.quirksmode.org/js/events_order.html and it is ambiguous in this part:
In the Microsoft model you must set the event’s
cancelBubble
property totrue
.window.event.cancelBubble = true
In the W3C model you must call the event’s
stopPropagation()
method.e.stopPropagation()
This stops all propagation of the event in the bubbling phase.
So my question is:
e.stopPropagation()
stop it, or does that only work for the bubble phase?Short answer: The order is:
If you call e.stopPropagation()
in the capture phase (by setting the addEventListener()
's 3rd argument to true
), it stops at 1, so 2 & 3 cannot receive it.
If you call e.stopPropagation()
in the bubble phase (by setting the addEventListener()
's 3rd argument to false
or just not assign it), the 1 & 2 already complete, so it just prevents the event from bubbling up from the level where you call stopPropagation()
.