Find out if a specific event is cancelable:
var x = event.cancelable;
Click the button to find out if the onclick event is a cancelable event.
<!DOCTYPE html> <html> <body> <button onclick="myFunction(event)">Test</button> <p id="demo"></p> <script> function myFunction(event) {/* w w w. ja v a2 s . co m*/ var x = event.cancelable; document.getElementById("demo").innerHTML = x; } </script> </body> </html>
The cancelable event property returns a Boolean value indicating whether or not an event is a cancelable event.
Possible values:
The event is cancelable if it is possible to prevent the events default action.
To cancel an event, use the preventDefault()
method.