The Bind method using jquery can bind more than one handler function for an event binding of an object, and can even bind a method multiple times, such as:
The code is as follows |
Copy Code |
$ (XXX). bind (' click ', Fun1). bind (' click ', Fun2). bind (' click ', fun1); |
Unbind is used to remove bindings, such as $ (XXX). Unbind (' click ')
......
But what if you just want to delete fun2? See a lot of jquery before the introduction of this operation, so nature has always thought only the whole will click processing, today tried another operation: $ (XXX). Unbind (' click ', fun2) to unbind fun2
Live: $ (XXX). Unbind (' click ', Fun1), will be registered before the two times fun1 all deleted
To delete a binding event
1. Remove binding events for all P elements:
The code is as follows |
Copy Code |
$ ("P"). Unbind (); |
2. Remove the Click event for the P element binding:
The code is as follows |
Copy Code |
$ ("P"). Unbind ("click"); $ ("P"). Unbind ("click", Funname); |
Note: The Unbind method only applies if you are using document.getElementById ("BTN") directly from the event that the jquery binding is canceled. Onclick=function{//code ...} or <div onclick= "alert (' C ')" >test</div>, cannot be canceled (deleted) by the Unbind method.
Remove Label method
The code is as follows |
Copy Code |
$ ("specified object"). Remove ();=> can be implemented $ ("#menuTree"). Unbind ()//removing all binding events $ ("#menuTree"). attr ("Class", "scroll org_tree white"); $ ("#menuTre ul"). Remove ()//delete tree |
Add:
Using the $ (selector). Unbind (' hover ') is invalid under jquery, you can use the following method instead:
The code is as follows |
Copy Code |
$ (selector). Unbind (' MouseEnter '). Unbind (' MouseLeave '); Or: $ (selector). Unbind (' MouseEnter mouseleave '); |
Hover events can be found to be composed of MouseEnter and mouseleave to distinguish between MouseOver and mouseout.
The mouseover and Mouseout events will not be affected after the two events that unbind it.