jQuery event.stopPropagation()

Beginner
⏱️ 9 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Event object · jQuery 1.0+

What You’ll Learn

event.stopPropagation() stops bubbling to parent elements while other handlers on the same element still run. This tutorial covers the official jQuery nested click demo, card inner-action patterns, comparing with stopImmediatePropagation() and return false, and checking state with isPropagationStopped().

01

Method

stopPropagation()

02

Returns

undefined

03

Official

Nested click demo

04

Same element

Handlers continue

05

Bubbling

Parents blocked

06

Since 1.0

No arguments

Introduction

When a user clicks a nested element, the click event bubbles from the inner target up through every ancestor. Parent handlers bound with .on() receive the same event unless something stops the bubble chain.

event.stopPropagation() halts that upward travel. jQuery has exposed this method since version 1.0 on its normalized event object. The official pattern calls it inside a handler on a nested element so parent handlers are not notified — while other handlers on the same element continue to run normally.

Understanding event.stopPropagation()

This method tells jQuery: do not bubble this event to parent elements.

  • Parent handlers blocked — ancestors in the DOM tree do not receive the event.
  • Same element continues — other handlers registered on the current target still run.
  • No arguments — call it with empty parentheses; returns undefined.
  • Check afterward — use event.isPropagationStopped() to verify the flag was set.
💡
Beginner Tip

Use stopPropagation() when you only need to block parent handlers — not when you must skip remaining handlers on the same element. For that, use stopImmediatePropagation() instead.

📝 Syntax

Official jQuery API form (since 1.0):

jQuery
event.stopPropagation()
// typical pattern:
$( "button" ).on( "click", function ( event ) {
  event.stopPropagation();
  // parent handlers are not notified
});

Parameters

  • None — this method does not accept any arguments.

Return value

  • undefined — the method stops bubbling as a side effect. Use event.isPropagationStopped() to check state afterward.

Official jQuery API example

jQuery
$( "p" ).on( "click", function ( event ) {
  event.stopPropagation();
  // Do something
});
$( "div" ).on( "click", function ( event ) {
  // This function won't be executed when p is clicked
  $( this ).css( "background-color", "#f00" );
});

⚡ Quick Reference

GoalAPIEffect
Stop bubbling to parentsevent.stopPropagation()Parent handlers skipped
Check if calledevent.isPropagationStopped()Returns Boolean
Skip remaining handlers + stop bubbleevent.stopImmediatePropagation()Handler queue halted
jQuery shorthandreturn falseprevent + stopPropagation (not immediate)
Cancel default actionevent.preventDefault()Separate concern

📋 stopPropagation() vs stopImmediatePropagation() vs return false vs isPropagationStopped()

Four related tools — stop bubbling only, halt the handler queue, jQuery shorthand, or read the flag.

stopPropagation
event.stopPropagation()

Stop bubbling; same-element handlers continue

stopImmediatePropagation
event.stopImmediatePropagation()

Skip remaining handlers + stop bubbling

return false
return false

prevent + stopPropagation (not immediate)

isPropagationStopped
event.isPropagationStopped()

Read flag (Boolean)

Examples Gallery

Example 1 follows the official jQuery nested click demo. Examples 2–5 cover same-element handler behavior, stop method comparison, card inner actions, and parent guard patterns with isPropagationStopped().

📚 Official jQuery Demo

Inner p handler stops propagation; parent div handler does not run.

Example 1 — Official Demo: nested click stops parent log

Official jQuery pattern — clicking inner p calls stopPropagation(); parent div handler never runs and the log stays empty for the parent.

jQuery
$( "div" ).on( "click", function () {
  $( "#log" ).append( "<div>div (parent) handler ran</div>" );
  $( this ).css( "background-color", "#f00" );
});
$( "p" ).on( "click", function ( event ) {
  event.stopPropagation();
  $( "#log" ).append( "<div>p handler ran — propagation stopped</div>" );
});
Try It Yourself

How It Works

stopPropagation() halts the bubble chain at the p element. The parent div handler is never notified when the inner paragraph is clicked.

Example 2 — Two handlers on same button — second still runs

First handler calls stopPropagation() to block a document-level parent handler — second handler on the same button still executes.

jQuery
$( document ).on( "click", function () {
  $( "#log" ).append( "document handler ran\n" );
});
$( "#btn" ).on( "click", function ( event ) {
  event.stopPropagation();
  $( "#log" ).append( "Handler 1 (stopPropagation)\n" );
});
$( "#btn" ).on( "click", function () {
  $( "#log" ).append( "Handler 2 still ran\n" );
});
Try It Yourself

How It Works

stopPropagation() affects bubbling only. jQuery continues running remaining handlers on the same element in registration order.

📈 Practical Patterns

Compare stop methods, card UI patterns, and parent guard checks.

Example 3 — stopPropagation vs stopImmediatePropagation side-by-side

Two buttons demonstrate the difference — stopPropagation() lets a second handler run; stopImmediatePropagation() does not.

jQuery
// Button A — stopPropagation only
$( "#btn-a" ).on( "click", function ( event ) {
  event.stopPropagation();
  $( "#log-a" ).append( "Handler 1 (stopPropagation)\n" );
});
$( "#btn-a" ).on( "click", function () {
  $( "#log-a" ).append( "Handler 2 still ran\n" );
});
// Button B — stopImmediatePropagation
$( "#btn-b" ).on( "click", function ( event ) {
  event.stopImmediatePropagation();
  $( "#log-b" ).append( "Handler 1 (stopImmediate)\n" );
});
$( "#btn-b" ).on( "click", function () {
  $( "#log-b" ).append( "Handler 2 still ran\n" );
});
Try It Yourself

How It Works

stopPropagation() halts bubbling but not the same-element queue. stopImmediatePropagation() does both — use it when later handlers on that element must not run.

Example 4 — Card click: inner action stops outer card toggle

Clickable card toggles open state — inner delete button calls stopPropagation() so the card toggle handler does not fire.

jQuery
$( ".card" ).on( "click", function () {
  $( this ).toggleClass( "open" );
  $( "#status" ).text( "Card toggled" );
});
$( ".card .delete" ).on( "click", function ( event ) {
  event.stopPropagation();
  $( "#status" ).text( "Delete clicked — card not toggled" );
});
Try It Yourself

How It Works

Nested interactive elements inside clickable containers are the most common real-world use case for stopPropagation() — isolate the inner action from the outer handler.

Example 5 — Parent handler skips when isPropagationStopped() is true

Delegated inner handler on #outer calls stopPropagation() first; a second outer handler checks event.isPropagationStopped() and skips.

jQuery
// Bound first — delegated handler on outer for inner clicks
$( "#outer" ).on( "click", ".inner", function ( event ) {
  event.stopPropagation();
  $( "#log" ).append( "delegated inner — stopped propagation\n" );
});
// Bound second — outer bubble handler guards with isPropagationStopped()
$( "#outer" ).on( "click", function ( event ) {
  if ( event.isPropagationStopped() ) {
    $( "#log" ).append( "outer skipped — propagation already stopped\n" );
    return;
  }
  $( "#log" ).append( "outer handler ran\n" );
});
Try It Yourself

How It Works

Multiple handlers on the same element run in registration order. The delegated inner handler stops propagation first; the outer handler bound second sees isPropagationStopped() as true and skips its logic.

🚀 Common Use Cases

  • Nested click targets — buttons or links inside clickable rows, cards, or list items.
  • Modal overlays — inner content clicks stop propagation so backdrop handlers do not close the dialog.
  • Dropdown menus — menu item clicks isolated from document-level close handlers until explicitly handled.
  • Table row actions — action icons inside selectable rows without triggering row selection.
  • Custom tooltips — interactive tooltip content stops propagation to parent hover/click handlers.
  • Debugging bubble chains — pair with isPropagationStopped() to trace where bubbling was halted.

🧠 How stopPropagation() Works

1

Event fires

User clicks a nested element — jQuery runs handlers on the target, then bubbles the event to each ancestor.

Trigger
2

Handler calls stop

A handler on the inner element calls event.stopPropagation() when parent handlers must not run.

Handler
3

Same-element queue continues

Remaining handlers on the current target still execute — only the upward bubble chain is halted.

Queue
4

Parents blocked

Ancestor handlers never receive the event. Use isPropagationStopped() to verify the flag.

📝 Notes

  • Available since jQuery 1.0 — returns undefined.
  • Takes no arguments — call with empty parentheses.
  • Stops bubbling to parent elements — parent handlers are not notified.
  • Does not stop other handlers on the same element from running.
  • Does not call preventDefault() — cancel defaults separately if needed.
  • return false in jQuery handlers calls preventDefault plus stopPropagation, not stopImmediatePropagation.
  • Use event.isPropagationStopped() (jQuery 1.3+) to check whether this method was called.

Browser Support

event.stopPropagation() is part of jQuery’s normalized event object since jQuery 1.0+. It wraps the native DOM stopPropagation() method so halting the bubble chain works consistently across browsers jQuery supports.

jQuery 1.0+ · all browsers

jQuery event.stopPropagation()

Stop event bubbling reliably.

100% Universal
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
stopPropagation() undefined

Bottom line: Call stopPropagation() to halt bubbling — call isPropagationStopped() to verify.

Conclusion

event.stopPropagation() is the standard way to prevent an event from reaching parent handlers in jQuery. The official nested click demo shows how an inner element can handle its own click without notifying ancestors — while other handlers on the same element continue to run.

Reach for it when nested UI needs isolated interactions — cards, rows, modals — and use isPropagationStopped() when parent or cooperative code needs to detect whether bubbling was already halted.

💡 Best Practices

✅ Do

  • Call event.stopPropagation() on inner elements inside clickable containers
  • Use when parent handlers should not run but same-element handlers should continue
  • Pair with isPropagationStopped() in cooperative parent/child setups
  • Combine with preventDefault() when you also need to cancel default actions
  • Prefer stopImmediatePropagation when same-element handlers must not run

❌ Don’t

  • Confuse with stopImmediatePropagation() — they halt different things
  • Assume stopPropagation() skips remaining handlers on the same element
  • Use stopPropagation when stopImmediatePropagation is what you need
  • Use it to cancel default browser actions — call preventDefault instead
  • Stop propagation on delegated events expecting to block handlers below in the DOM tree that already ran

Key Takeaways

Knowledge Unlocked

Five things to remember about stopPropagation()

Stop bubbling, not same-element handlers.

5
Core concepts
02

Returns

undefined

Value
demo 03

Official

Nested click

Demo
queue 04

Same element

Handlers continue

Use
05

Not immediate

Bubbling only

Compare

❓ Frequently Asked Questions

event.stopPropagation() prevents the event from bubbling up the DOM tree so parent handlers are not notified. It takes no arguments, returns undefined, and has been available since jQuery 1.0. Other handlers on the same element still run.
Call it when a child element handler must run without triggering parent handlers — for example, a button inside a clickable card, or an inner link that should not activate an outer row click handler.
stopPropagation() stops bubbling to parent elements but other handlers on the same element still run. stopImmediatePropagation() stops both bubbling and any remaining handlers on the same element.
Yes. In jQuery handlers, return false calls preventDefault() and stopPropagation(). It does not call stopImmediatePropagation(), so remaining handlers on the same element may still run.
Use event.isPropagationStopped(). It returns true if stopPropagation() was called on this event object during the current dispatch, and false otherwise. Available since jQuery 1.3.
No. stopPropagation() affects bubbling only. To cancel default actions like link navigation or form submit, call event.preventDefault() separately.
Did you know?

event.stopPropagation() has been part of jQuery’s event object since version 1.0 — predating stopImmediatePropagation() (1.3) and the isPropagationStopped() check (1.3). The method mirrors the native DOM Level 2 stopPropagation() and works for custom events triggered with .trigger() as well.

Next: event.isPropagationStopped()

Check whether stopPropagation() was called on the event object.

isPropagationStopped() tutorial →

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.

6 people found this page helpful