Event: cancelBubble property

Deprecated

Avoid using this feature in new projects. This feature may be a candidate for removal from web standards or browsers.

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