event.stopPropagation() prevents further travel of the current event in the capturing and bubbling phases (MDN). Other listeners on the same element still run. Defaults (links, forms) are not canceled.
Pass the required arguments shown below. Check return values and browser support before you rely on the result.
Syntax
Call event.stopPropagation. Start with this line.
JavaScript
event.stopPropagation()
Call
What it does
event.stopPropagation()
Primary signature.
event.stopPropagation(...)
Call with the arguments your case needs.
Built into the browser. Call stopPropagation(...) on an Event instance — no import required.
Library declarations
JavaScript
event.stopPropagation()
Parameters
This member has no parameters beyond those shown in the signature.
Return Value
Return Value
Description
*
undefined
JavaScript Examples
Example 1 — Stop Bubbling to Parent
Child click logs; the parent listener does not run.
JavaScript
child.addEventListener("click", (event) => {
console.log("child");
event.stopPropagation();
});
parent.addEventListener("click", () => {
console.log("parent"); // does not run for child clicks
});
Two listeners on the button. Added in order 1 then 2.
Handler 1 stops travel. Path to parents is cut.
Handler 2 still runs. MDN: same-element listeners are not skipped.
Need to skip them? Use stopImmediatePropagation().
Example 3 — Does Not Cancel Defaults
Stopping bubble keeps parents quiet; a link still navigates unless you also preventDefault.
JavaScript
link.addEventListener("click", (e) => {
e.stopPropagation();
console.log("bubble stopped — link may still navigate");
// e.preventDefault(); // uncomment to stay on the page
});
parent.addEventListener("click", () => {
console.log("parent"); // does not run
});
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.