jQuery event.isDefaultPrevented()

Beginner
5 min read
Updated: Oct 2026
5 examples
Live preview

What Is event.isDefaultPrevented()?

event.isDefaultPrevented() returns a Boolean: true if event.preventDefault() was called on this event, otherwise false. Added in jQuery 1.3. Takes no arguments.

Remember
event.isDefaultPrevented()  // Boolean — no arguments

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

// Pair with: preventDefault() to cancel
// Not the same as: isPropagationStopped() (bubbling flag)
NeedUse
Cancel defaultevent.preventDefault()
Check if cancelledevent.isDefaultPrevented()
Stop bubblingevent.stopPropagation()
Check bubbling stopevent.isPropagationStopped()
Bind handler.on("click", fn)

How to Use isDefaultPrevented()

Call it on the event object before or after preventDefault().

  1. Bind a handler with .on() and accept event.
  2. Optionally read event.isDefaultPrevented() early (usually false).
  3. Call event.preventDefault() when you need to cancel the default.
  4. Call event.isDefaultPrevented() again — now true.
  5. In a later handler on the same event, branch if the default was already cancelled.
PieceRequired?Role
eventYesjQuery event object in the handler
preventDefault()To cancelSets the flag this method reads
isDefaultPrevented()—Returns true / false
ArgumentsNoneMethod takes no parameters

Pseudocode

Pseudocode
element.on("click", handler)

when event fires:
    flag = false
    call handler(event):
        event.isDefaultPrevented() → flag   // usually false first
        if need to cancel:
            event.preventDefault()
            flag = true
        event.isDefaultPrevented() → flag   // true after prevent

// Later handler on same event:
if event.isDefaultPrevented():
    skip fallback default logic
else:
    maybe allow or prevent yourself

Cheat Sheet

Keep these facts handy while coordinating handlers.

TopicDetail
ReturnsBoolean
SincejQuery 1.3
ArgumentsNone
Official demofalse → preventDefault() → true
return falseAlso makes this return true (jQuery)
Native cousinevent.defaultPrevented (property)
Undo?No — flag stays set for that event
Official docsapi.jquery.com/event.isDefaultPrevented

Live Preview

Click the link. See the flag before and after preventDefault() — same idea as the official jQuery API demo.

Demo link

Navigation is cancelled — the log shows false then true.

Click this link

Log
Waiting — click the link.

jQuery Examples

Short, copy-ready snippets. Open DevTools, or use Try It Yourself for a live editor.

Example 1 — Official: False, Then True

Check the flag before and after preventDefault() on a link.

jQuery
$("a").on("click", function (event) {
  var before = event.isDefaultPrevented();
  event.preventDefault();
  var after = event.isDefaultPrevented();
  $("#out").text(
    "Before: " + before + "\\nAfter: " + after
  );
});
Try It Yourself

How It Works

  1. Click. The link handler runs.
  2. Before. Nothing cancelled yet → false.
  3. Prevent. preventDefault() blocks navigation.
  4. After. The flag is set → true.

Example 2 — Later Handler Checks the Flag

First handler may prevent; second handler reacts to that state.

jQuery
$("#go").on("click", function (event) {
  if ($("#block").prop("checked")) {
    event.preventDefault();
  }
});

$("#go").on("click", function (event) {
  if (event.isDefaultPrevented()) {
    $("#out").text("Blocked — default already prevented.");
  } else {
    $("#out").text("Allowed — default not prevented.");
  }
});
Try It Yourself

How It Works

  1. First handler. Conditionally calls preventDefault().
  2. Second handler. Runs later on the same click.
  3. Check. isDefaultPrevented() reflects the earlier call.
  4. Branch. UI can skip fallback logic when already blocked.

Example 3 — Guard a Form Submit

Prevent submit when empty; confirm the flag in the same handler.

jQuery
$("#form").on("submit", function (event) {
  if ($("#name").val().trim() === "") {
    event.preventDefault();
  }
  $("#out").text(
    "isDefaultPrevented: " + event.isDefaultPrevented()
  );
});
Try It Yourself

How It Works

  1. Submit. The form handler runs.
  2. Validate. Empty name → call preventDefault().
  3. Report. Log whether the default was cancelled.
  4. Filled. No prevent → flag stays false (form may navigate).

Example 4 — return false Sets the Flag

In jQuery, return false implies preventDefault() — a second handler sees true.

jQuery
$("#link").on("click", function () {
  return false; // preventDefault + stopPropagation
});

$("#link").on("click", function (event) {
  $("#out").text(
    "Second handler: isDefaultPrevented = " +
    event.isDefaultPrevented()
  );
});
Try It Yourself

How It Works

  1. First handler. return false cancels the default (and stops bubbling).
  2. Same element. A second handler on the same link still runs.
  3. Flag. It sees isDefaultPrevented() === true.
  4. Prefer. New code should call preventDefault() explicitly.

Example 5 — Default vs Propagation Flags

Prevent default without stopping bubble — compare the two checks.

jQuery
$("#child").on("click", function (event) {
  event.preventDefault();
  $("#out").text(
    "defaultPrevented: " + event.isDefaultPrevented() + "\\n" +
    "propagationStopped: " + event.isPropagationStopped()
  );
});
Try It Yourself

How It Works

  1. Prevent. Cancels the default action only.
  2. Default flag. isDefaultPrevented() → true.
  3. Bubble flag. Still false — bubbling was not stopped.
  4. Separate. Use the matching stop/check pair for each concern.

Edge Cases & Pitfalls

Watch for these when using isDefaultPrevented().

read-only

Cannot undo the flag

Once preventDefault() runs, the default stays cancelled for that dispatch.

order

Handler order matters

A later handler only sees true if an earlier one (or itself) already called preventDefault().

return false

return false also sets it

In jQuery, return false implies prevent + stop bubble. Prefer explicit preventDefault().

vs bubble

Not a bubbling check

Use isPropagationStopped() for stopPropagation() state.

Browser Support

event.isDefaultPrevented() is a jQuery event-object method available since 1.3. It mirrors the idea of the native defaultPrevented property on a normalized event. Works wherever your loaded jQuery version runs.

✓ Stable · jQuery 1.3+

isDefaultPrevented()

Supported in jQuery 1.3–3.x. Prefer jQuery 3.x with .on() handlers. Native equivalent: event.defaultPrevented (boolean property).

100% With jQuery 1.3+
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 jQuery 1.3+

Bottom line: Safe for production. Call preventDefault() to cancel; call isDefaultPrevented() to ask whether it already happened.

Performance Notes

ApproachCostBest for
event.isDefaultPrevented()FreeReading a boolean flag
event.preventDefault()CheapCancelling navigation / submit
Many handlers checking the flagCheapCoordinating plugin + app handlers

The method is a simple flag read. Use it when coordination matters — not on every single handler by habit.

Key Takeaways

  • Role: ask whether preventDefault() already ran.
  • Returns: false then true after prevent (official demo).
  • Coordinate: later handlers can skip fallback defaults.
  • Not bubbling: use isPropagationStopped() for that flag.

One line: isDefaultPrevented() answers “did someone already cancel the default?”

Frequently Asked Questions

It returns true if event.preventDefault() was called on this event object during handler execution, and false otherwise. It takes no arguments. Available since jQuery 1.3.
When multiple handlers run on the same event and a later one needs to know whether an earlier handler already cancelled the default action — for example, skipping fallback navigation after a link was prevented.
In jQuery handlers, return false calls both preventDefault() and stopPropagation(). After return false, isDefaultPrevented() returns true. Prefer explicit event.preventDefault() for clarity.
Same idea. Native events expose a defaultPrevented boolean. jQuery provides isDefaultPrevented() as a method on its normalized event object for a consistent API.
No. isDefaultPrevented() only reports state. Once preventDefault() runs, the default action stays cancelled for that event dispatch.
isDefaultPrevented() reports whether the browser default was cancelled (link navigation, form submit). isPropagationStopped() reports whether bubbling was stopped. Different flags.

Next: stopImmediatePropagation()

Stop remaining handlers on the same element and 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.

9 people found this page helpful