event.isDefaultPrevented() Method - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:event.isDefaultPrevented


The event.isDefaultPrevented() method checks whether the preventDefault() method was called.


Parameter Description
event Required. The event parameter comes from the event binding function

The following code shows how to Prevent a link from opening the URL, and check if preventDefault() was called:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
        event.preventDefault();/*from  ww  w . ja va2s . c  o m*/
        console.log("Was preventDefault() called: " + event.isDefaultPrevented());

<a href="http://java2s.com/">Go to site</a>


Related Tutorials