Performance: see
Download the latest jquery 1.42 framework
You can also directly introduce the following in the webpage:
Http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js
Http://ajax.microsoft.com/ajax/jQuery/jquery-1.4.2.min.js
Add method:
. Delegate (selector, eventtype, Handler)
This function is indeed very useful. Attaches an event listener to a specified object.
Selector: Selector
Eventtype: Event Type
Handler: Listener Function
The delegate method is used to replace the. Live () method in 1.3.2. This method is more convenient than live, and can also be used to dynamically add events.
Let's look at the following example: bind a hover event to each TD in the table
The previous statement is as follows:
CopyCode The Code is as follows: $ ("table"). Each (function (){
$ ("TD", this). Live ("hover", function (){
$ (This). toggleclass ("hover ");
});
});
As long:Copy codeThe Code is as follows: $ ("table"). Delegate ("TD", "hover", function (){
$ (This). toggleclass ("hover ");
});
One line of code.
Of course, since there is. Delegate (), there is also. undelegate (), used to unbind the event