jQuery unbind Remove Binding Event and Remove Label Method
- 2021-07-24 10:03:39
- OfStack
jQuery unbind Remove Binding Event
unbind ([type], [data]) is the reverse of bind (), deleting the bound event from every 1 matched element. If there are no parameters, all bound events are deleted. You can unbind custom events that you registered with bind (). If an event type is provided as an argument, only bound events of that type are deleted. If you take the handler passed at binding time as the second argument, only this particular event handler will be removed.
Return value: jQuery
Parameters:
type (String): (Optional) Event Type
data (Function): (optional) the event handler to unbind from the events of each matching element
Example: Unbind all events in all paragraphs
jQuery code:
$("p").unbind()
Unbind the click event of a paragraph
jQuery code:
$("p").unbind( "click" )
Delete the binding of a specific function and pass the function as the second parameter
jQuery code:
var foo = function () {
// Code that handles an event
};
$("p").bind("click", foo); // ... Triggered when a paragraph is clicked foo
$("p").unbind("click", foo); // ... It will never be triggered again foo
Remove label method:
$(" Specify an object ").remove();=> It can be realized
$("#menuTree").unbind();// Remove all binding events
$("#menuTree").attr("class","scroll org_tree white");
$("#menuTre ul").remove();// Delete a tree