cancelable Event Property

Example

Is the event cancelable:

// true or false?
event.cancelable;
Try it Yourself »

Description

The cancelable event property returns true if an event is cancelable.

Otherwise it returnsfalse.

The cancelable event property is read-only.

An event is cancelable if it is possible to prevent its default action.

Event Bubbling

Event bubbling directs an event to its target. It works like this:

When an element (like a button) is clicked, an event is directed to the element.
If an event handler is set for the element, the event handler is triggered.
Then the event "bubbles up" to the elements parent.
If an event handler is set for the parent, this event handler is triggered.
The event continues to bubble, until it reaches the top (the document element).

Prevent Bubbling:

The stopPropagation() Method stops bubbling.


Prevent Default Action:

The preventDefault() Method cancels an event (the default action will not occur).


Syntax

event.cancelable

Technical Details

Return Value: A Boolean.
Returns true if the event is cancelable.
Otherwise it returns false.
DOM Version: DOM Level 2 Events.

Browser Support

event.canceable is a DOM Level 2 (2001) feature.

It is fully supported in all browsers:

Chrome Edge Firefox Safari Opera IE
Yes Yes Yes Yes Yes 9-11


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.