How to use isDefaultprevented() Method event in jQuery

This article describe about isDefaultprevented() Method in jQuery.
  • 3417

jQuery Event isDefaultPrevented() Method

Weather or not the preventDefault() method is called for the specified event object, it return by the isDefaultPrevented() method.

Syntax

event.isDefaultPrevented()

 

Parameter Description
event Required. It define to check. The event parameter comes to the event bind method

Example

<!DOCTYPE html>

<html>

<head>

<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">

    $(document).ready(function () {

        $("a").click(function (event) {

            event.preventDefault();

            alert("Default prevented: " + event.isDefaultPrevented());

        });

    });

</script>

</head>

<body>

<a href="/">Go to dotnetheaven.com</a>

<p>The preventDefault() method will prevent the link above from the URL.</p>

<p>Click on link and check if the default action is prevented.</p>

</body>

</html>

 

Output

 

isDefaultprevent method pic 16.jpg


Note: After click on the link.

 

IsDefaultprevent pic17.jpg

 

You may also want to read these related articles Click here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.