JavaScript Event stopPropagation() Method

Beginner
⏱️ 12 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Baseline Widely available
Instance method

What You’ll Learn

The stopPropagation() method prevents further propagation of the current event in the capturing and bubbling phases. Same-element listeners still run. Learn how it differs from preventDefault() and stopImmediatePropagation()—with five examples and try-it labs.

01

Kind

Instance method

02

Returns

undefined

03

Params

None

04

Stops

Further path

05

Same el

Listeners OK

06

Status

Baseline widely

Introduction

When you click a button inside a div, the event can travel: capture down the tree, then bubble back up. A parent listener often hears the same click—useful for delegation, annoying when the parent should not react.

Call event.stopPropagation() to stop that further travel. Other handlers on the same button still run. Links still navigate unless you also call preventDefault(). To skip remaining same-element listeners too, use stopImmediatePropagation().

💡
Beginner tip

“Stop propagation” = stop traveling to other elements. “Prevent default” = stop the browser’s built-in action. They solve different problems.

Understanding Event.stopPropagation()

An instance method that prevents further propagation of the current event in the capturing and bubbling phases.

  • No parameters — call event.stopPropagation().
  • Return value — none (undefined).
  • Stops further path — parents (bubble) or deeper nodes (if called during capture) do not receive it later.
  • Same-element listeners — still run (unlike stopImmediatePropagation).
  • Defaults unchanged — use preventDefault() to cancel navigation / submit / etc.
  • Baseline Widely available on MDN (since July 2015); also in Web Workers.

📝 Syntax

JavaScript
stopPropagation()

Parameters

None.

Return value

None (undefined).

Typical pattern

JavaScript
child.addEventListener("click", (event) => {
  event.stopPropagation();
  // Parent click listeners will not hear this click
});

⚡ Quick Reference

GoalCode / note
Stop bubbling to parentevent.stopPropagation()
Also skip same-element leftoversevent.stopImmediatePropagation()
Cancel link / form defaultevent.preventDefault()
Both stop + cancelCall both methods when needed
MDN statusBaseline Widely available (since July 2015)

🔍 At a Glance

Four facts to remember about stopPropagation().

Stops
path

Capture + bubble

Same el
runs

Other handlers OK

Default
unchanged

Use preventDefault

Baseline
widely

Since Jul 2015

Examples Gallery

Examples follow MDN Event: stopPropagation() and pair well with the stopImmediatePropagation compare demos.

📚 Getting Started

Stop a parent from hearing a child click.

Example 1 — Stop Bubbling to the Parent

Child logs; parent does not.

JavaScript
child.addEventListener("click", (event) => {
  out.textContent += "child\n";
  event.stopPropagation();
});
parent.addEventListener("click", () => {
  out.textContent += "parent\n";
});
Try It Yourself

How It Works

Without stopPropagation(), a bubbling click would also run the parent listener.

Example 2 — Same-Element Listeners Still Run

Handlers 1–3 on the button all fire; parent is skipped.

JavaScript
btn.addEventListener("click", (e) => {
  out.textContent += "1\n";
  e.stopPropagation();
});
btn.addEventListener("click", () => { out.textContent += "2\n"; });
btn.addEventListener("click", () => { out.textContent += "3\n"; });
// → 1, 2, 3  (parent skipped)
Try It Yourself

How It Works

This is the MDN distinction vs stopImmediatePropagation().

📈 Defaults, Nesting & Capture

Combine with preventDefault; isolate nested UI; note capture.

Example 3 — Propagation vs Default Action

Stopping bubble does not stop a link from navigating—add preventDefault.

JavaScript
link.addEventListener("click", (event) => {
  event.stopPropagation();   // parent won't hear
  event.preventDefault();    // browser won't navigate
  out.textContent = "Stopped path + canceled navigation";
});
Try It Yourself

How It Works

MDN: stopPropagation does not prevent default behaviors such as link clicks.

Example 4 — Nested Cards (Click Inside Should Not Select Outer)

A common UI pattern: inner control stops the outer card’s click handler.

JavaScript
card.addEventListener("click", () => {
  out.textContent = "Card selected";
});
closeBtn.addEventListener("click", (event) => {
  event.stopPropagation();
  out.textContent = "Close only — card not selected";
});
Try It Yourself

How It Works

Without the stop, the close click would bubble and also “select” the card.

Example 5 — Calling During Capture Stops Further Travel

A capture listener on an ancestor can stop the event before the target.

JavaScript
parent.addEventListener("click", (event) => {
  out.textContent += "parent capture\n";
  event.stopPropagation();
}, true); // capture

child.addEventListener("click", () => {
  out.textContent += "child\n"; // skipped when capture stopped
});
Try It Yourself

How It Works

MDN covers both capturing and bubbling: further propagation in those phases is prevented.

🚀 Common Use Cases

  • Inner buttons that must not trigger an outer card / row click handler.
  • Dropdown menus where clicks inside should not close via a document listener (with care).
  • Isolating third-party widgets from page-level click analytics.
  • Teaching bubble vs capture with a clear “stop here” demo.
  • Pairing with preventDefault for full control of a link or form control.

🔧 How It Works

1

Event travels

Capture down, then at-target, then bubble up.

Path
2

You call stopPropagation

Further nodes on the path will not receive this event.

Stop
3

Same target continues

Other listeners on the current element still run in order.

Local
4

Defaults separate

Browser default still needs preventDefault if you want it canceled.

📝 Notes

  • MDN: Baseline Widely available (since July 2015) — no Deprecated / Experimental / Non-standard banner.
  • Available in Web Workers.
  • Does not cancel default actions—see preventDefault().
  • Does not skip remaining same-element listeners—see stopImmediatePropagation().
  • Related learning: stopImmediatePropagation(), preventDefault(), cancelBubble, bubbles, eventPhase.

Universal Browser Support

Event.stopPropagation() is marked Baseline Widely available on MDN (since July 2015). Logos use the shared browser-image-sprite.png sprite from this project. It is also available in Web Workers.

Baseline · Widely available

Event.stopPropagation()

Prevents further propagation in the capturing and bubbling phases; same-element listeners still run.

Universal Widely available
Google Chrome Full support · Desktop & Mobile
Full support
Mozilla Firefox Full support · Desktop & Mobile
Full support
Apple Safari Full support · macOS & iOS
Full support
Microsoft Edge Full support · Chromium
Full support
Opera Full support · Modern versions
Full support
Internet Explorer Supported in legacy IE (prefer modern browsers)
Legacy
Event.stopPropagation() Excellent

Bottom line: Use stopPropagation to isolate nested UI clicks; pair with preventDefault when you also need to cancel defaults.

Conclusion

Event.stopPropagation() stops further capture/bubble travel while letting other listeners on the current element finish. Reach for stopImmediatePropagation() when those must be skipped too, and preventDefault() when the browser default must go.

Continue with MouseEvent(), stopImmediatePropagation(), eventPhase, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Use it to isolate nested interactive UI
  • Prefer it over stopImmediate when same-element handlers should run
  • Call preventDefault separately when needed
  • Know whether you listen in bubble or capture
  • Prefer stopPropagation over deprecated cancelBubble

❌ Don’t

  • Expect it to cancel link navigation alone
  • Use it everywhere—delegation often wants bubbling
  • Confuse it with stopImmediatePropagation
  • Assume parents already ran in capture are undone
  • Fight document-level closers without a clear UX plan

Key Takeaways

Knowledge Unlocked

Five things to remember about stopPropagation()

Stop the path—not the default, not same-element leftovers.

5
Core concepts
🔁02

Same el

still runs

Local
🚫03

≠ default

use preventDefault

Pair
04

< immediate

softer stop

Compare
🎯05

Baseline

since Jul 2015

Status

❓ Frequently Asked Questions

It prevents the current event from traveling further in the capturing and bubbling phases. Other listeners on the same element still run. It does not cancel the browser default action.
No. MDN marks Event.stopPropagation() as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard. It is also available in Web Workers.
stopPropagation() still allows remaining listeners on the current element to run, then stops further travel. stopImmediatePropagation() also skips those remaining same-element listeners.
preventDefault() cancels the browser default (link navigation, form submit, and so on). stopPropagation() only affects which other elements hear the event.
It stops further propagation in both capturing and bubbling. Listeners that already ran are not undone. Calling it during capture prevents the event from continuing down (and later up) the tree.
Event.cancelBubble is a deprecated legacy flag related to stopping propagation. Prefer stopPropagation() in modern code.
Did you know?

Event delegation (one listener on a parent) depends on bubbling. Overusing stopPropagation() can break those patterns—prefer it for specific nested controls, not as a global habit.

Next: MouseEvent()

Build synthetic mouse events and control how they propagate.

MouseEvent() →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful