CKTIS / JavaScript
Event.stopPropagation() — stopping event propagation
stopPropagation() stops further event propagation without canceling the default action or the remaining listeners in the current invocation.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
event.stopPropagation()event.stopPropagation() is a DOM Web API method, not an ECMAScript function. It returns undefined. It stops further propagation during either capturing or bubbling; it does not undo listeners already executed. Calling it on an ancestor during capturing can prevent the event from reaching its target.
It does not interrupt the current callback or the remaining listeners in the current invocation on the same object. stopImmediatePropagation() also stops those remaining listeners. preventDefault() serves a different purpose: it cancels the default action when the event and invocation conditions allow it.
In the example, capturing on parent happens first. The first child listener blocks bubbling to parent, but the second still runs. defaultPrevented remains false. Run the code in a browser; the presence of Node 24 does not prove support for the browser DOM.
Examples
const parent = document.createElement('div');
const child = document.createElement('button');
parent.append(child);
const log = [];
parent.addEventListener('demo', () => log.push('parent capture'), true);
parent.addEventListener('demo', () => log.push('parent bubble'));
child.addEventListener('demo', (event) => {
log.push('child first');
event.stopPropagation();
});
child.addEventListener('demo', () => log.push('child second'));
const event = new Event('demo', { bubbles: true, cancelable: true });
child.dispatchEvent(event);
log.push(`defaultPrevented: ${event.defaultPrevented}`);
console.log(log.join('\n'));Result
parent capture child first child second defaultPrevented: false
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.