Javascript examples for jQuery Method and Property:die
The die() method removes event handlers added with the live() method.
The die() method was deprecated in jQuery version 1.7, and removed in version 1.9. Use the off() method instead.
$(selector).die(event,function);
Parameter | Require | Description |
---|---|---|
event | Required. | one or more event handlers to remove. |
function | Optional. | a specific function to remove |
The following code shows how to Remove all event handlers added with the live() method for all <p> elements:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"> </script>/*from w w w.j a va2 s.com*/ <script> $(document).ready(function(){ $("p").live("click", function(){ $(this).slideToggle(); }); $("button").click(function(){ $("p").die(); }); }); </script> </head> <body> <p>This is a paragraph.</p> <p>This is another paragraph.</p> <p>Click any p element to make it disappear.</p> <button>Remove event handlers</button><br><br> </body> </html>