jQuery .die() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Event Handler

Definition

.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);
CallWhat 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

ParameterDescription
eventTypeUsed in .die(eventType). Remove live handlers for one event type
handlerUsed in .die(eventType, handler). Remove one specific live handler function
eventsUsed in .die(events). Map of event types (and optional handlers) to remove

Return Value

Return ValueDescription
Value / undefinedGetters 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
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.

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.

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.

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: .on() Method

Control this when passing methods as event handlers.

.on() Method tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

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