jQuery die() Method

jQuery die() method is used to removes one or more event handlers, used with the live() method, for the selected elements.

The die() method was deprecated in jQuery 1.7. and removed om jQuery 1.9.

Syntax

This syntax represent to the die event

$(selector).die(eventType, function);
Parameter Type Description
eventType String Required. Specifies one or more DOM event types (such as "click" or "dblclick" or custom event names) to attach to the elements
function Function Optional. Specifies the function to execute when the event is occurs

Example

This example represent the die event, once die event trigger it will remove event handles on the selected elements.

<!DOCTYPE html>
<html>
<head>
  <title>jQuery die() method</title>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
  <script>
    $(document).ready(function(){
      $("p").live("click", function(){
        alert("clicked");
      });
      $("button").click(function(){
        $("p").die();
      });
    });
  </script>
</head>
<body>
  <div>
    <p>first paragraph text</p>
    <p>second paragraph text</p>
  </div>
  <button>Click here to remove above p element "click" event handler</button>
</body> 
</html>

Run it...   »