Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. JavaScript Course

Lesson 11 of 55 · javascript

Event Propagation – Capturing, Bubbling & `stopPropagation`

Duration: 10 mins

When an event occurs it travels through three phases:

  1. Capturing – from the window down to the target.
  2. At target – the event reaches the target element.
  3. Bubbling – back up from the target to window.

You can control the phase with the third argument of addEventListener:

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

Use e.stopPropagation() to halt further propagation, or e.stopImmediatePropagation() to also stop other listeners on the same element.

Example: Stop bubbling

div.addEventListener('click', e => {
  e.stopPropagation();
  console.log('Div clicked – event will not reach body');
});
Previous: Event Handling – Adding & Removing ListenersNext: The `this` Keyword – Binding Rules