HTML | DOM cancelable Event Property

The cancelable Event property is used to indicate whether or not an event can have its default actions prevented. If the default actions can be prevented the value is true, else the value is false. It is a read-only property.
Syntax:

event.cancelable

Return Value: It returns a Boolean which indicates whether the event is cancelable or not.

  • It returns true indicating the event is cancelable.
  • It returns false indicating the event is not cancelable.

Example:



filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
      
<head>
    <title>DOM cancelable Event Property</title>
</head>
  
<body style="text-align:center">
  
    <h1 style="color: green;">
        GeeksforGeeks
    </h1>
      
    <h2>
        DOM cancelable Event Property
    </h2>
  
    <button onclick="Geeks(event)">Click Here!</button>
      
    <p id="p"></p>
      
    <script>
        function Geeks(event) { 
            var x = event.cancelable;
            document.getElementById("p").innerHTML = 
                                    "Cancelable: " + x;
        }
    </script>
</body>
</html>                    

chevron_right


Output:
Before clicking on the button:
cancelable
After clicking on the button:
cancelable
Supported Browsers: The browser supported by cancelable Event property are listed below:

  • Apple Safari
  • Google Chrome
  • Firefox
  • Opera
  • Internet Explorer


My Personal Notes arrow_drop_up


If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.