Home >>jQuery Tutorial >jQuery event.preventDefault() Method

jQuery event.preventDefault() Method

jQuery event.preventDefault() Method

jQuery event.preventDefault() method in jQuery is used to stops the default action of an element from happening like, you can Prevent a link from following the URL and Prevent a submit button from submitting a form.

Syntax:
event.preventDefault()

Parameter Values

Parameter Description
event It is a required parameter and is used to specidy the event parameter comes from the event binding function
Here is an Example of jQuery event.preventDefault() Method:

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".myLink").click(function(event){
event.preventDefault();
});
});
</script>
</head>
<body>
<a class="myLink" href="https://phptpoint.com/">Go to phptpoint.com</a>
</body>
</html>

Output:
Go to phptpoint.com

No Sidebar ads