HTML cancelable Event Property

HTMLWeb DevelopmentFront End Technology

The cancelable event property in HTML checks whether an event is a cancelable event or not. The values include TRUE if it is a cancelable event, else FALSE is returned.

Following is the syntax −

event.cancelable

Let us now see an example to implement the cancelable event property −

Example

 Live Demo

<!DOCTYPE html>
<html>
<body>
   <h2>Checking cancelable event</h2>
   <p>The below button will display whether the event is cancelable or not.</p>
   <button onclick="myFunction(event)">Click me</button>
   <p id="myid"></p>
   <script>
      function myFunction(event) {
         var val = event.cancelable;
         document.getElementById("myid").innerHTML = val;
      }
   </script>
</body>
</html>

Output

Now, click on the button to display whether the event is cancelable or not. A boolean value would be returned −

raja
Published on 19-Jun-2019 12:14:17
Advertisements