jQuery .die() Method

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

What Is .die()?

.die([eventType] [, handler]) removes handlers previously attached with .live() (since 1.3; no-arg form 1.4.1). It is the legacy counterpart to modern .off().

Remember
// Legacy (jQuery ≤ 1.8)
$("p").live("click", foo);
$("p").die("click", foo);   // remove that handler
$("p").die("click");        // remove all live click handlers on "p"
$("p").die();               // remove all live handlers on "p"

// Modern equivalent
$(document).on("click", "p", foo);
$(document).off("click", "p", foo);
NeedUse
Remove modern handlers.off()
Attach modern handlers.on()
Legacy live attach.live() (removed 1.9)
Legacy live remove.die() (removed 1.9)
Remove .delegate() handlers.undelegate()

How to Use .die()

Only when reading or migrating pre-1.9 code that used .live().

  1. Confirm the original bind used .live() with a specific selector.
  2. Call .die() on the same selector string.
  3. Optionally pass an event type, and optionally the exact handler function.
  4. Prefer rewriting to .on() / .off() instead of keeping .die().
FormSinceRole
.die()1.4.1Remove all .live() handlers for that selector
.die(eventType)1.3Remove live handlers for one event type
.die(eventType, handler)1.3Remove one specific live handler function
.die(events)1.4.3Map of event types (and optional handlers) to remove

Pseudocode

Pseudocode
handlers were stored under SELECTOR by .live()

call $(SELECTOR).die(optional EVENT, optional HANDLER):

    find live handlers keyed by SELECTOR

    if no args:
        remove all of them
    else if EVENT only:
        remove live handlers for that EVENT
    else:
        remove only that HANDLER for EVENT

modern rewrite:
    $(document).off(EVENT, SELECTOR [, HANDLER])

Cheat Sheet

Quick facts for legacy code reviews.

TopicDetail
ReturnsjQuery (chainable)
Added1.3 · no-arg 1.4.1 · map 1.4.3
Deprecated1.7
Removed1.9
Pairs with.live()
Modern pair.on() / .off()
Selector ruleMust match the original .live() selector exactly

Live Preview

Modern .on() / .off() stand-in for the old .live() / .die() pair (works in current jQuery).

Click the sample paragraph after binding. True .die() demos are in Try It Yourself (jQuery 1.8.3).

Status
Ready — Run “bind”, then click the sample.

jQuery Examples

Legacy patterns for reading old code. Prefer .off() in new projects. Try It Yourself runs on jQuery 1.8.3.

Example 1 — Remove All Live Handlers

No arguments — clear every .live() handler for that selector.

jQuery
$("p").live("click", function () {
  $("#out").text("clicked");
});

$("p").die(); // all live handlers on "p" gone
Try It Yourself

How It Works

  1. Bind. .live("click", …) registers a document-level handler for "p".
  2. Die. .die() with no args clears all live entries for that selector.
  3. Result. Clicks on paragraphs no longer run those handlers.
  4. Modern. $(document).off("click", "p") (or broader .off()).

Example 2 — Remove by Event Type

Keep other live events; drop only click.

jQuery
$("p").live("click", onClick);
$("p").live("mouseover", onHover);

$("p").die("click"); // mouseover live handler remains
Try It Yourself

How It Works

  1. Two binds. Separate live handlers for click and mouseover.
  2. Filter. .die("click") targets only click.
  3. Keep. Other event types for that selector stay.
  4. Modern. $(document).off("click", "p").

Example 3 — Remove One Handler Function

Pass the same function reference you used with .live().

jQuery
var foo = function () {
  $("#out").text("foo ran");
};

$("p").live("click", foo);
$("p").die("click", foo); // only foo is removed
Try It Yourself

How It Works

  1. Named fn. Store the handler in a variable.
  2. Live. Attach that exact function with .live().
  3. Die. Pass the same reference to remove only that one.
  4. Modern. $(document).off("click", "p", foo).

Example 4 — Migrate to .off()

Side-by-side rewrite for current jQuery.

jQuery
// Legacy ≤ 1.8
$("p").live("click", foo);
$("p").die("click", foo);

// Preferred (1.7+)
$(document).on("click", "p", foo);
$(document).off("click", "p", foo);
Try It Yourself

How It Works

  1. Root. Modern code binds on document (or a closer parent).
  2. On. Selector moves to the second argument of .on().
  3. Off. Remove with the same event + selector + handler.
  4. Drop. Delete .live() / .die() from the codebase.

Example 5 — Exact Selector Match

Wrong selector string → handler stays alive.

jQuery
$("p.note").live("click", foo);

$("p").die("click");      // does NOT remove it
$("p.note").die("click"); // does remove it
Try It Yourself

How It Works

  1. Key. Live storage uses the exact selector string.
  2. Mismatch. "p" ≠ "p.note" as a lookup key.
  3. Match. Call .die() with the same selector as .live().
  4. Modern. Same idea — .off("click", "p.note") must match the .on() selector.

Edge Cases & Pitfalls

Common traps when reading or migrating .die() code.

removed

Missing on jQuery 1.9+

$(…).die is not a function means the page loaded a modern jQuery — rewrite to .off().

selector

Selector must match exactly

A different string than the original .live() call leaves the handler in place.

pair

Only removes .live() handlers

.die() does not remove .bind(), .delegate(), or .on() handlers.

reference

Anonymous functions are hard to die

To remove one handler, keep a named function reference — or use .die(eventType) to clear that type.

Browser Support

.die() existed from jQuery 1.3 to 1.8. It was deprecated in 1.7 and removed in 1.9. Current jQuery builds do not include it.

✓ Removed · jQuery 1.3–1.8

.die()

Not available in jQuery 1.9+. Use .off() with .on() for all new and upgraded projects.

Removed Use .off() instead
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
.die() Removed 1.9

Bottom line: Historical API only. Migrate live/die pairs to on/off when you touch legacy code.

Performance Notes

ApproachCostBest for
.off() on a close rootLowModern cleanup of delegated handlers
Keeping .live() / .die()N/ABlocked on jQuery 1.9+ — must migrate
Document-wide live handlersBroader filteringPrefer closer roots with .on()

There is no performance win to keeping .die() — the migration target is clearer roots and .off(), which also works on current jQuery.

Key Takeaways

  • Role: remove handlers attached with .live().
  • Status: deprecated 1.7, removed 1.9 — not in modern jQuery.
  • Migrate: .live() → .on(), .die() → .off().
  • Selector: must match the original .live() string exactly.

One line: .die() was the undo for .live() — learn it to read old code, write new code with .off().

Frequently Asked Questions

.die() removes event handlers previously attached with .live(). It is the unbind counterpart to .live(), similar to how .off() removes handlers attached with .on().
No. .die() was deprecated in jQuery 1.7 and removed in jQuery 1.9. Current jQuery 3.x builds do not include it. Use .off() instead. jQuery Migrate 1.x can restore .live()/.die() temporarily while upgrading.
Replace .live() with .on() on a root (often document), then replace .die() with .off(). Example: $('p').live('click', fn) → $(document).on('click', 'p', fn), and $('p').die('click') → $(document).off('click', 'p').
.live() stored handlers keyed by the selector string. .die() looks them up the same way. Binding with $('p.note').live('click', fn) requires $('p.note').die('click') — $('p').die('click') will not remove it.
It removes all handlers previously attached with .live() for that selector — a broad cleanup, similar to calling .off() with no filter on a modern delegated binding.
.die() removes document-level .live() handlers. .undelegate() removes handlers attached with .delegate() on a chosen root. Both are legacy; .off() replaces them in modern jQuery.

Next: jQuery.proxy()

Control this when passing methods as event handlers.

jQuery.proxy() 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.

8 people found this page helpful