English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
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.
event.preventDefault()
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 | Description |
---|---|
event | TheEventParameters come from the event binding feature |