.die()

Remove event handlers previously attached using .live() from the elements.

.die()🡢 jQuery

.die(eventType, function())🡢 jQuery

eventType StringA string containing a JavaScript event type, such as click or keydown.
function() StringThe function that is no longer to be executed.

.die(events)🡢 jQuery

events PlainObjectA plain object of one or more event types, such as click or keydown and their corresponding functions that are no longer to be executed.

Note: This API has been removed in jQuery 1.9; please use on() instead.

Any handler that has been attached with .live() can be removed with .die(). This method is analogous to calling .off() with no arguments, which is used to remove all handlers attached with .on(). See the discussions of .live() and .off() for further details.

If used without an argument, .die() removes all event handlers previously attached using .live() from the elements.

As of jQuery 1.7, use of .die() (and its complementary method, .live()) is not recommended. Instead, use .off() to remove event handlers bound with .on()

Note: In order for .die() to function correctly, the selector used with it must match exactly the selector initially used with .live().

To unbind all live events from all paragraphs, write:

HTML
$("p").die();
DEMO

To unbind all live click events from all paragraphs, write:

HTML
$("p").die("click");
DEMO

To unbind just one previously bound handler, pass the function in as the second argument:

HTML
var foo = function () {
  // Code to handle some kind of event
};

// Now foo will be called when paragraphs are clicked
$("p").live("click", foo);

// Now foo will no longer be called
$("p").die("click", foo);
DEMO

Looking for a Web Developer?

👋

Hi! I'm Basti, author of this site. If you are looking for a web developer with 15+ years of experience, holla at me!

Be it the good 'ol jQuery, vanilla JS or modern frameworks like Vue and Svelte, front- or backend, I can help you.

Just write me at jobs@jqapi.com :)