Unbind (type [, data]) //data is the function to be removed $ ('#btn'). Unbind (" Click " // Remove Click$ ('#btn'// Remove all
For a case that only needs to be triggered once and then immediately unbound, use one ()
$ ('#btn'). One ("click", function () {...});
Trigger action: the trigger () method triggers the specified event type for the selected element.
$ ('#btn'). Trigger ("click");
Trigger Custom Event: the bind () method adds one or more event handlers for the selected element and specifies the function to run when the event occurs.
$ ('#btn'). Bind ("myclick", function () {...});
Impersonation triggers the above binding function
$ ('#btn'). Trigger ("myclick");
Pass Data trigger (EVENT,[PARAM1,PARAM2,...])
$ ('#btn'). Bind ("myclick", Function (event, Message1,message2) () {...}); $ ('#btn'). Trigger ("myclick", [" Pass it to Message1 "," passed to Message2"]);
Triggering the execution of the default action
$ ("input"). Trigger ("Focus"); // not only does it trigger the focus event that the input element binds to, it also triggers the default action--Get Focus
Triggers only binding events, not browser default actions
$ ("input"). Triggerhandler ("Focus"); // triggers only binding events, not browser default actions
Other usage
Binding multiple Event types
$ ("div"). Bind ("mouseover mouseout", function () {...});
To add an event namespace
$ ("div"). Bind ("click.plugin", function () {...});
Add a namespace after the event type you are binding so that you only need to specify the namespace when you delete the event.
$ ("div"). Unbind (". Plugin"); // Delete the event within the space $ ("div"). Trigger ("click! " // trigger so does not include the click Method in the namespace
If it is included in the namespace, it will also be triggered
$ ("div"). Trigger ("click");
Cancel or bind a function
$ ('div'). Bind ('click', recommandproduct); // bind the Recommandproduct function $ ('div') for Div. Unbind ('click ', recommandproduct); // Cancel the Recommandproduct function
jquery remove, bind, trigger element events