I am trying to understand what true or false does when adding addEventListener in Internet Explorer. According to Microsoft it is useCapture. If I add an event such as:
element.addEventListener('click', function_name, true);
It does not appear to change anything, the listener still works. Can anyone explain the purpose of useCapture parameter please?
It is the optional useCapture parameter that specifies the event phase to add the event handler for:
Events are handled in two phases: capturing and bubbling. During the capturing phase, events are dispatched to parent objects before they are dispatched to event targets that are lower in the object hierarchy. During the bubbling phase, events are dispatched to target elements first and then to parent elements. You can register event handlers for either event phase.
true Register the event handler for the capturing phase.
false Register the event handler for the bubbling phase.
You can read the eventPhase documentation here: http://msdn.microsoft.com/en-gb/library/ie/ff974944(v=vs.85).aspx
EDIT:
Please read the following that describes the event order defined by bubbling and capturing with clear examples. http://www.quirksmode.org/js/events_order.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With