jQuery event.isDefaultPrevented()

Beginner
⏱️ 9 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Event object · jQuery 1.3+

What You’ll Learn

event.isDefaultPrevented() returns whether event.preventDefault() was called on this event. This tutorial covers the official link demo, blocking navigation and form submit, coordinating multiple handlers, return false, and comparing with native defaultPrevented.

01

Method

isDefaultPrevented()

02

Returns

Boolean

03

Official

false → true

04

preventDefault

Sets flag

05

Handlers

Multi-listener

06

Since 1.3

No arguments

Introduction

Many events have a default browser action — links navigate, forms submit, checkboxes toggle. Calling event.preventDefault() cancels that action. But how does a later handler know cancellation already happened? Call event.isDefaultPrevented().

jQuery has exposed this check since version 1.3 on its normalized event object. The official demo alerts false, calls preventDefault(), then alerts true — proving the flag flips when default action is blocked.

Understanding event.isDefaultPrevented()

This method answers one question: was default action cancelled on this event?

  • Before preventDefaultevent.isDefaultPrevented() returns false.
  • After preventDefault — returns true for the rest of that event dispatch.
  • Read-only — takes no arguments; does not change state.
  • Multiple handlers — a later handler can branch on the flag set by an earlier one.
💡
Beginner Tip

Call preventDefault() to block navigation or submit. Call isDefaultPrevented() to check whether someone already blocked it — useful when several handlers share one click or submit event.

📝 Syntax

Official jQuery API form (since 1.3):

jQuery
event.isDefaultPrevented()

// typical pattern:
$( "a" ).on( "click", function ( event ) {
  if ( !event.isDefaultPrevented() ) {
    // default not cancelled yet
  }
  event.preventDefault();
  if ( event.isDefaultPrevented() ) {
    // now true
  }
});

Parameters

  • None — this method does not accept any arguments.

Return value

  • Booleantrue if event.preventDefault() was called on this event object; otherwise false.

Official jQuery API example

jQuery
$( "a" ).on( "click", function ( event ) {
  alert( event.isDefaultPrevented() ); // false
  event.preventDefault();
  alert( event.isDefaultPrevented() ); // true
});

⚡ Quick Reference

ActionAPIAfter call
Cancel defaultevent.preventDefault()isDefaultPrevented() === true
Check if cancelledevent.isDefaultPrevented()Boolean
jQuery shorthandreturn falseAlso sets flag true
Native equivalentevent.defaultPreventedProperty, not method
Stop bubbling onlystopPropagation()Use isPropagationStopped()

📋 preventDefault() vs isDefaultPrevented() vs return false

Three related tools — one cancels, one checks, one does both cancel and stop bubbling.

preventDefault
event.preventDefault()

Cancel default action

isDefaultPrevented
event.isDefaultPrevented()

Read flag (Boolean)

return false
return false

prevent + stopPropagation

defaultPrevented
event.originalEvent.defaultPrevented

Native property

Examples Gallery

Example 1 follows the official jQuery demo. Examples 2–5 cover links, form submit, chained handlers, and return false.

📚 Official jQuery Demo

Alert false, call preventDefault, alert true.

Example 1 — Official Demo: false then true

Official jQuery demo — on link click, show the flag before and after event.preventDefault().

jQuery
$( "a" ).on( "click", function ( event ) {
  alert( event.isDefaultPrevented() ); // false
  event.preventDefault();
  alert( event.isDefaultPrevented() ); // true
});
Try It Yourself

How It Works

preventDefault() sets an internal flag on the event object. isDefaultPrevented() reads that flag — the official demo proves the transition from false to true in one handler.

📈 Practical Patterns

Forms, handler chains, and return false.

Example 3 — AJAX Form: submit handler checks flag

First handler prevents native submit; logging handler reads isDefaultPrevented().

jQuery
$( "#myForm" ).on( "submit", function ( event ) {
  event.preventDefault();
});

$( "#myForm" ).on( "submit", function ( event ) {
  console.log( "Submit default prevented?", event.isDefaultPrevented() );
});
Try It Yourself

How It Works

jQuery runs bound handlers in registration order on the same event. The second handler sees the flag set by the first handler’s preventDefault().

Example 4 — Conditional fallback: skip if already prevented

Only run custom navigation when no earlier handler cancelled default.

jQuery
$( document ).on( "click", "a.external", function ( event ) {
  if ( event.isDefaultPrevented() ) return;
  event.preventDefault();
  window.open( this.href, "_blank" );
});
Try It Yourself

How It Works

isDefaultPrevented() lets cooperative handlers respect prior cancellation instead of fighting over the same click.

Example 5 — return false sets the flag

jQuery return false triggers preventDefault — isDefaultPrevented() becomes true.

jQuery
$( "#btn" ).on( "click", function ( event ) {
  console.log( "before:", event.isDefaultPrevented() );
  return false;
});

$( "#btn" ).on( "click", function ( event ) {
  console.log( "after sibling:", event.isDefaultPrevented() );
});
Try It Yourself

How It Works

return false is jQuery sugar for preventDefault() plus stopPropagation(). Prefer explicit calls in new code; know that either way isDefaultPrevented() reflects cancellation.

🚀 Common Use Cases

  • Debug handlers — log isDefaultPrevented() after custom logic runs.
  • AJAX forms — confirm submit was prevented before sending XHR.
  • Link interceptors — skip fallback when another plugin already prevented navigation.
  • Validation plugins — invalid field handlers call preventDefault(); analytics handlers check the flag.
  • Testing — assert isDefaultPrevented() after simulating clicks in Try-it labs.
  • Library cooperation — avoid double preventDefault when integrating third-party code.

🧠 How isDefaultPrevented() Works

1

Event fires

User clicks link or submits form — jQuery creates a normalized event object; flag starts false.

Start
2

Handler runs

isDefaultPrevented() returns false until something cancels default.

Check
3

preventDefault()

Handler (or return false) sets the flag — browser default will not run.

Cancel
4

Flag stays true

Later handlers read isDefaultPrevented() === true for the same dispatch.

📝 Notes

  • Available since jQuery 1.3 — returns a Boolean.
  • Takes no arguments — read-only query method.
  • Reports whether preventDefault() was ever called on this event object.
  • Does not report propagation state — use isPropagationStopped() for that.
  • return false in jQuery handlers also sets default prevented.
  • Native defaultPrevented property exists on modern events; jQuery wraps consistently.

Browser Support

event.isDefaultPrevented() is part of jQuery’s normalized event object since jQuery 1.3+. It mirrors the native default-prevented flag across browsers jQuery supports, including environments where reading defaultPrevented directly was inconsistent.

jQuery 1.3+ · all browsers

jQuery event.isDefaultPrevented()

Check whether default action was cancelled.

100% Universal
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
isDefaultPrevented() Boolean

Bottom line: Call preventDefault() to cancel — call isDefaultPrevented() to verify.

Conclusion

event.isDefaultPrevented() tells you whether default action was cancelled on the current event dispatch. The official demo shows it flip from false to true immediately after preventDefault().

Use it when multiple handlers share one event and later code must respect earlier cancellation — especially with links, forms, and plugin combinations.

💡 Best Practices

✅ Do

  • Call event.preventDefault() explicitly in new code
  • Check isDefaultPrevented() before fallback navigation logic
  • Use on submit handlers before AJAX replacement
  • Log the flag while debugging multi-handler bugs
  • Pair with preventDefault() — one cancels, one verifies

❌ Don’t

  • Call isDefaultPrevented() expecting to reset the flag
  • Confuse with isPropagationStopped()
  • Assume false after you called preventDefault()
  • Rely on return false without knowing it also stops propagation
  • Skip preventDefault and only check the flag — you must cancel first

Key Takeaways

Knowledge Unlocked

Five things to remember about isDefaultPrevented()

Read whether default was cancelled.

5
Core concepts
stop 02

preventDefault

Sets true

Pair
demo 03

Official

false → true

Demo
form 04

Submit

AJAX forms

Use
RF 05

return false

Also cancels

Note

❓ Frequently Asked Questions

event.isDefaultPrevented() returns true if event.preventDefault() was called on this event object at any point during handler execution, and false otherwise. It is a read-only check — you cannot pass arguments. Available since jQuery 1.3.
Use it when multiple handlers run on the same event and a later handler needs to know whether an earlier one already cancelled the default action — for example, skipping fallback navigation when a link click was already prevented.
In jQuery handlers, return false calls both preventDefault() and stopPropagation(). After return false, isDefaultPrevented() returns true. Prefer explicit event.preventDefault() in modern code for clarity.
Native events expose a defaultPrevented property (read-only boolean). jQuery provides isDefaultPrevented() as a method that wraps the same idea on its normalized event object for consistency across browsers, including older ones jQuery supported.
No. isDefaultPrevented() only reports state — it does not reset the flag. Once preventDefault() runs, the default action stays cancelled for that event dispatch.
isDefaultPrevented() reports whether the browser default action was cancelled (link navigation, form submit). isPropagationStopped() reports whether stopPropagation() was called to halt bubbling. They track different event flags.
Did you know?

jQuery added isDefaultPrevented() and isPropagationStopped() together in version 1.3 so handler code could inspect event state without reaching into browser-specific properties. Modern native events expose defaultPrevented, but jQuery’s method keeps tutorial and legacy code consistent.

Next: event.stopImmediatePropagation()

Stop remaining handlers on the same element and halt bubbling.

stopImmediatePropagation() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful