jQuery event.preventDefault() method
Example
Prevent a link from opening a URL:
$("a").click(function(event){
event.preventDefault();
});
Try it »
Definition and Usage
The event.preventDefault() method prevents the element from performing its default action.
For example:
- Prevent form submission when the submit button is clicked
- Prevent the link to the following URL
**Tip:** Please use event.isDefaultPrevented() method to check whether the preventDefault() method was called on the specified event.
Syntax
event
.preventDefault()
| Parameters | Description |
|---|---|
| event | Required.event The parameters come from the event binding function. |
jQuery event methods