Home >Web Front-end >JS Tutorial >Usage examples of die() method in jQuery
This article mainly introduces the usage of the die() method in jQuery. The example analyzes the function, definition and removal of all the die() method added to the specified element through the live() method. For tips on using multiple event handling programs, friends in need can refer to
This article explains the usage of the die() method in jQuery with examples. Share it with everyone for your reference. The specific analysis is as follows:
This method removes all one or more event handlers added to the specified element through the live() method.
Grammar structure:
The code is as follows:
$(selector).die(type,function)
Parameter list:
Example code:
The code is as follows:
<!DOCTYPE html> <html> <head> <meta charset=" utf-8"> <meta name="author" content="http://www.jb51.net/" /> <title>脚本之家</title> <style type="text/css"> p{border:1px solid blue;} li { list-style-type :none; width:150px; height:150px; border:1px solid green; } </style> <script type="text/ javascript " src="mytest/jQuery/jquery-1.8.3.js"></script> <script type="text/javascript"> $( document ).ready(function(){ $("p").live("click",function(){ $("li").slideToggle(); }); $("button").click(function(){ $("p").die(); }); }) </script> </head> <body> <p> <ul> <li>脚本之家</li> </ul> </p> <button>删除添加</button> </body> </html>
The above is the detailed content of Usage examples of die() method in jQuery. For more information, please follow other related articles on the PHP Chinese website!