event.preventDefault() cancels the browser’s default action for the current event. Clicked anchors will not navigate; forms will not submit — unless you allow them. Takes no arguments, returns undefined. Available since jQuery 1.0. Check with event.isDefaultPrevented().
Syntax
Start with these common calls. Keep them short and readable.
jQuery
event.preventDefault() // no args · returns undefined
$("a").on("click", function (event) {
event.preventDefault(); // stay on this page
});
// Does NOT stop bubbling — use stopPropagation() for that
// return false in jQuery = preventDefault + stopPropagation
Call
What it does
Cancelable event
e.g. link click, form submit
event argument
jQuery event object
preventDefault()
Blocks the browser default
Custom logic
What you do instead
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
Step 1
Bind the event that has a default (click on links, submit on forms).
Step 2
In the handler, call event.preventDefault().
Step 3
Run your own logic (update UI, AJAX, SPA route, validation message).
Return Value
Return Value
Description
Value / undefined
Getters usually return a value from the first matched element, or undefined when nothing applies.
jQuery Examples
Example 1 — Official Demo: Prevent Link Navigation
Cancel the default click and append a log line (official idea).
Bind submit. Form submit is the event with a default reload.
Cancel.preventDefault() keeps you on the page.
Read.serialize() shows what would have been posted.
Frequently Asked Questions
event.preventDefault() cancels the browser’s default action for the current event — for example, stopping a link from navigating or a form from submitting. It takes no arguments and returns undefined. Available since jQuery 1.0.
Call it when you handle the event in JavaScript and want to replace the native behavior — SPA link clicks, AJAX form submits, custom validation before submit, or any time the default action would interfere with your code.
No. preventDefault() only cancels the default browser action. The event still bubbles to parents unless you also call event.stopPropagation() or return false from a jQuery handler.
In jQuery handlers, return false calls both preventDefault() and stopPropagation(). preventDefault() alone cancels the default action but lets bubbling continue — useful when parent handlers should still run.
No. Once preventDefault() runs on an event dispatch, the default action stays cancelled for that dispatch. Use event.isDefaultPrevented() to check whether it was already called.
It works on cancelable events — click on links, submit on forms, and similar. Some events are not cancelable; calling preventDefault() on them has no effect.