jQuery event.stopPropagation() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Events

Definition

event.stopPropagation() prevents the event from bubbling up the DOM tree, so parent handlers are not notified. Takes no arguments, returns undefined. Since jQuery 1.0. Other handlers on the same element still run. Check with isPropagationStopped(). Also works with custom events from .trigger().

Syntax

Start with these common calls. Keep them short and readable.

jQuery
event.stopPropagation()   // no args

$("p").on("click", function (event) {
  event.stopPropagation();   // parents will not hear this click
});

// Same-element handlers: still run
// To also skip them → stopImmediatePropagation()
CallWhat it does
event.stopPropagation()Learn jQuery event.stopPropagation(): stop event bubbling to parents while same-element handlers still run, official nested click demo, vs stopImmediatePropagation, card patterns, examples, pitfalls, and FAQs.

Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.

Parameters

ParameterDescription
Step 1Bind a handler on the inner element (button, link, paragraph, …).
Step 2Inside that handler, call event.stopPropagation().
Step 3Parent handlers will not run for this event.

Return Value

Return ValueDescription
BooleanOften true or false depending on the match or state.
Value / undefinedGetters usually return a value from the first matched element, or undefined when nothing applies.

jQuery Examples

Example 1 — Nested Click: Stop the Parent

Inner element stops bubbling so the parent click handler never runs.

jQuery
$("#parent").on("click", function () {
  $("#out").append("parent handler ran\n");
});

$("#child").on("click", function (event) {
  event.stopPropagation();
  $("#out").append("child ran — propagation stopped\n");
});
Try It Yourself

How It Works

  1. Parent. Listens for clicks on the outer area.
  2. Child. Calls stopPropagation() on its click.
  3. Bubble ends. Parent is not notified for that click.

Example 2 — Same-Element Handlers Still Run

Stopping bubble does not skip other handlers on the same button.

jQuery
$(document).on("click", function () {
  $("#out").append("document handler ran\n");
});

$("#btn").on("click", function (event) {
  event.stopPropagation();
  $("#out").append("Handler 1 (stopPropagation)\n");
});

$("#btn").on("click", function () {
  $("#out").append("Handler 2 still ran\n");
});
Try It Yourself

How It Works

  1. Document. Would hear the bubble if it continued.
  2. Handler 1. Stops propagation toward ancestors.
  3. Handler 2. Still runs on the same button.

Example 3 — vs stopImmediatePropagation()

Immediate also kills the same-element queue; stopPropagation does not.

jQuery
$("#btn-a").on("click", function (event) {
  event.stopPropagation();
  $("#out").append("A1 (stopPropagation)\n");
});
$("#btn-a").on("click", function () {
  $("#out").append("A2 still ran\n");
});

$("#btn-b").on("click", function (event) {
  event.stopImmediatePropagation();
  $("#out").append("B1 (stopImmediate)\n");
});
$("#btn-b").on("click", function () {
  $("#out").append("B2 still ran\n");
});
Try It Yourself

How It Works

  1. Button A. stopPropagation — A2 still runs.
  2. Button B. stopImmediatePropagation — B2 is skipped.
  3. Both. Stop ancestor bubbling.

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 handler must run without triggering parent handlers — for example, a button inside a clickable card, or an inner control that should not activate an outer row click.
stopPropagation() stops bubbling to parents 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 same-element handlers may still run.
Use event.isPropagationStopped(). It returns true if stopPropagation() was called on this event object during the current dispatch. Available since jQuery 1.3.
No. It affects bubbling only. To cancel link navigation or form submit, call event.preventDefault() separately.

Next: event.isPropagationStopped() Method

Learn how to detect whether stopPropagation() already ran.

event.isPropagationStopped() Method tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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.

10 people found this page helpful