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
Fundamentals
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.
Concept
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.
Foundation
📝 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" );
});
Cheat Sheet
⚡ Quick Reference
Goal
API
Effect
Stop bubbling to parents
event.stopPropagation()
Parent handlers skipped
Check if called
event.isPropagationStopped()
Returns Boolean
Skip remaining handlers + stop bubble
event.stopImmediatePropagation()
Handler queue halted
jQuery shorthand
return false
prevent + stopPropagation (not immediate)
Cancel default action
event.preventDefault()
Separate concern
Compare
📋 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)
Hands-On
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.
Click p → #log shows "p handler ran — propagation stopped"
"div (parent) handler ran" never appears
Click div background → parent handler runs, div turns red
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.
Button A: Handler 1 + Handler 2 both run
Button B: Handler 1 only — Handler 2 skipped
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.
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" );
});
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.
Applications
🚀 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.
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.
Important
📝 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.
Compatibility
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 ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
stopPropagation()undefined
Bottom line: Call stopPropagation() to halt bubbling — call isPropagationStopped() to verify.
Wrap Up
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.
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
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about stopPropagation()
Stop bubbling, not same-element handlers.
5
Core concepts
stop01
stopProp
Block parent handlers
API
∅02
Returns
undefined
Value
demo03
Official
Nested click
Demo
queue04
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.