.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().
Syntax
Start with these common calls. Keep them short and readable.
jQuery
// 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);
Call
What it does
.die()
Remove all .live() handlers for that selector
.die(eventType)
Remove live handlers for one event type
.die(eventType, handler)
Remove one specific live handler function
.die(events)
Map of event types (and optional handlers) to remove
Load jQuery before your script (CDN or local file), then wrap DOM work in $(function () { ... }) when needed.
Parameters
Parameter
Description
eventType
Used in .die(eventType). Remove live handlers for one event type
handler
Used in .die(eventType, handler). Remove one specific live handler function
events
Used in .die(events). Map of event types (and optional handlers) to remove
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 — 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
Before die → foo runs on click
After die(click, foo) → foo does not run
How It Works
Named fn. Store the handler in a variable.
Live. Attach that exact function with .live().
Die. Pass the same reference to remove only that one.
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.