Remove all event handlers added with the live()
method for all <p> elements:
Remove event handlers, added with the live()
method, for p elements
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"> </script>/*ww w .j av a2 s . co m*/ <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>Test</button><br><br> </body> </html>
The die()
method was deprecated in jQuery version 1.7, and removed in version 1.9.
Use the off()
method instead.
The die()
method removes one or more event handlers, added with the live()
method.
$(selector).die(event,function)
Parameter | Optional | Description |
---|---|---|
event | Required. | one or more event handlers to remove. Multiple event values are separated by space. Must be a valid event |
function | Optional. | a specific function to remove |