Junior JavaScript

What is event bubbling and capturing?

When an event occurs in a nested element:

  • Bubbling: Event moves upward (child → parent).
  • Capturing: Event moves downward (parent → child).

Example:

element.addEventListener('click', handler, true); // capturing

element.addEventListener('click', handler, false); // bubbling

More from JavaScript Tutorial

All questions for this course