Skip to content

Latest commit

 

History

History
16 lines (12 loc) · 565 Bytes

0305.md

File metadata and controls

16 lines (12 loc) · 565 Bytes

Capturing Bubbles

Event Propagation

  1. An element intercepts an event
  2. Browser collects DOM node path of the event from the starting element to the root
  3. Capture: the event propagates down the path from step 2
  4. Bubble: the event propagates up the path from step 2

By default, event listeners do not trigger until the bubbling phase Triggering events at the capture phase can be done by adding true as a third argument to addEventListener.

x.addEventListener("click", foo, true)

You can cancel event propagation with e.stopPropagation()