Event: cancelBubble property

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

Note: This feature is available in Web Workers.

The cancelBubble property of the Event interface is deprecated. Use Event.stopPropagation() instead. Setting its value to true before returning from an event handler prevents propagation of the event. In later implementations, setting this to false does nothing. See Browser compatibility for details.

Value

A boolean value. The value true means that the event must not be propagated further.

Example

js
elem.onclick = (event) => {
  // Do cool things here
  event.cancelBubble = true;
};

Specifications

Specification
DOM
# dom-event-cancelbubble

Browser compatibility

desktop mobile server
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Bun
Deno
Node.js
cancelBubble
Deprecated
Chrome – Full support
Chrome 1 (Release date: 2008-12-11)
footnote
footnote Starting with Chrome 58 and Opera 45, setting this property to false does nothing, as per spec discussion.
Edge – Full support
Edge 12 (Release date: 2015-07-29)
footnote Full support
Firefox – Partial support
Firefox 1 – 52 (Release date: 2004-11-09)
footnote Partial support
footnote Only supported for UIEvent, not all Event objects.
Firefox – Full support
Firefox 53 (Release date: 2017-04-19)
footnote Full support
Opera – Full support
Opera 12.1 (Release date: 2012-11-20)
footnote
footnote Starting with Chrome 58 and Opera 45, setting this property to false does nothing, as per spec discussion.
Safari – Full support
Safari 1 (Release date: 2003-06-23)
footnote Full support
Chrome Android – Full support
Chrome Android 18 (Release date: 2012-06-27)
footnote
footnote Starting with Chrome Android 58 and Opera 45, setting this property to false does nothing, as per spec discussion.
Firefox for Android – Partial support
Firefox for Android 4 – 52 (Release date: 2011-03-29)
footnote Partial support
footnote Only supported for UIEvent, not all Event objects.
Firefox for Android – Full support
Firefox for Android 53 (Release date: 2017-04-19)
footnote Full support
Opera Android – Full support
Opera Android 12.1 (Release date: 2012-10-09)
footnote
footnote Starting with Chrome 58 and Opera 45, setting this property to false does nothing, as per spec discussion.
Safari on iOS – Full support
Safari on iOS 1 (Release date: 2007-06-29)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1 (Release date: 2013-04-27)
footnote
footnote Starting with Samsung Internet 7.0 and Opera 45, setting this property to false does nothing, as per spec discussion.
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
footnote
footnote Starting with WebView Android 58 and Opera 45, setting this property to false does nothing, as per spec discussion.
WebView on iOS – Full support
WebView on iOS 1 (Release date: 2007-06-29)
footnote Full support
Bun – Full support
Bun 1 (Release date: 2023-09-08)
footnote Full support
Deno – Full support
Deno 1 (Release date: 2020-05-13)
footnote Full support
Node.js – Full support
Node.js 14.5 (Release date: 2020-06-30)
footnote
footnote This is not used in Node.js and is provided purely for completeness.

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
Deprecated. Not for use in new websites.
See implementation notes.
Has more compatibility info.