Did you find this useful?
Socialize it today.

jQuery Die Event

Tuesday, June 19, 2012

The jQuery event die() method removes one or more event handlers previously attached using .live() method from the elements. As of jQuery 1.7, the use of .die() and .live() is not recommended. The recommended approach is to use .off() to remove event handlers bound with .on().



eventOne or more events to attach. Event values are separated by space
functionOptional function to run when the event(s) occur

Basic Example

In the following jQuery example, the die() method removes the click event from the element with an id of "imgMouse". When the "imgDie" element is clicked, the "click" event is removed from "imgMouse". In this example, the div element will be shown or hidden as the mouse icon is clicked. Clicking the Die image removes this event. Try it yourself, by clicking the mouse icon first, then the Die image. You can copy, paste, and modify this code using our online HTML editor (found below in the resources section).

<div id="divParent">
    <img id="imgMouse"src="#" />
    <img id="imgDie"src="#" />
    <div id="divChild">
    <div id="divText">Click the mouse icon to toggle ....

$("#imgMouse").live("click", function () {
$("#imgDie").click(function () {

mouse close
Click the mouse icon to toggle this display, or click the X to remove the event handler!

Please help us spread the word by socializing it today!

email contact us

Did you find something wrong with the information on this page? Please take a moment to report it to us so that we can continue to improve the quality of the information on this site. Click here to report an issue with this page.

Recommended Books & Training Resources

HTML CSS and JavaScript Editor JavaScript and jQuery: The Missing Manual Professional jQuery