JavaScript › DOM & Events
What's the difference between the capturing and bubbling phases of event propagation?
AdvancedAnswer
Events actually travel in three phases: capturing (top-down, from window to the target), target phase, then bubbling (bottom-up, target back to window). Listeners default to the bubbling phase; pass { capture: true } to react during the capturing phase instead.
el.addEventListener('click', handler, { capture: true }); // fires during capture (top-down)
el.addEventListener('click', handler); // fires during bubble (bottom-up), the defaultReal-world example Intercepting a click at a top-level container BEFORE it reaches a deeply nested element that might call stopPropagation().