Methods to remove events: 1. Use unbind(), the syntax is "the element that is bound to the mouse event.unbind()"; 2. Use unelegate(), the syntax is "the element that is bound to the mouse event. undelegate();"; 3. Use off(), the syntax is "the element bound to the mouse event.off()".
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
Jquery method to remove mouse events:
Method 1: Use unbind() method
## The #unbind() method removes the event handler of the selected element. This method can remove all or selected event handlers, or terminate the execution of the specified function when an event occurs. ubind() works with any event handler attached via jQuery. Example:Method 2: Use undelegate() method
undelegate() Method removes one or more event handlers added by the delegate() method. Example:Method 3: Use off() method
off() method is usually used For removing event handlers added via the on() method. Note: As of jQuery version 1.7, the off() method is the new replacement for the unbind(), die(), and undelegate() methods. This method brings a lot of convenience to the API and is recommended because it simplifies the jQuery code base. [Recommended learning:jQuery video tutorial,web front-end video]
The above is the detailed content of How to remove mouse events in jquery. For more information, please follow other related articles on the PHP Chinese website!