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
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Event Propagation – Capturing, Bu | JavaScript Course lesson | BraveProgrammer
  1. Courses
  2. /
  3. JavaScript Course

Lesson 11 of 55

·javascript

Event Propagation – Capturing, Bubbling & `stopPropagation`

10 mins

Course progress20%

What you'll learn

Keep these ideas in mind as you work through the lesson.

3 points
  • Only events that are **bubbling** (most UI events) can be intercepted on parent elements.
  • Use **capturing** when you need to act *before* the target’s own listeners.
  • `stopImmediatePropagation` is rarely needed – use with caution.

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');
});
Make it stickPractice what you've learned1 quiz · 7 practical tests · Optional activities from JavaScript CourseBrowse activities
Previous lessonEvent Handling – Adding & Removing ListenersContinue to lesson 12The `this` Keyword – Binding RulesBack to JavaScript Course curriculum