English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

jQuery event.preventDefault() Method

jQuery Events

The event.preventDefault() method can prevent the browser from executing the default action of the selected element.

For example:

  • Prevent the link from following the URL

  • Prevent the submit button from submitting the form

Usageevent.isDefaultPrevented()The method checks if the preventDefault() method was called during the event.

Syntax:

event.preventDefault()

Instance

Prevent the link from opening the URL:

$("a").click(function(event){
  event.preventDefault();
});
Test and see‹/›

Prevent the submit button from submitting the form:

$("#submit").click(function(event){
  event.preventDefault();
});
Test and see‹/›

Parameter Value

ParameterDescription
eventTheEventParameters come from the event binding feature

jQuery Events