In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article focuses on "how to remove mouse events in jquery". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "jquery how to remove mouse events"!
Methods to remove events: 1, with unbind (), syntax "bind the element of mouse event .unbind ()"; 2, with undelegate (), syntax "bind element of mouse event .undelegate ()"; 3, with off (), syntax "bind element of mouse event .off ()".
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
Jquery's method of removing mouse events:
Method 1: use the unbind () method
The unbind () method removes the event handler for the selected element.
This method can remove all or selected event handlers, or terminate the operation of the specified function when the event occurs.
Ubind () applies to any event handler attached through jQuery.
Example:
$(document) .ready (function () {$("p") .click (function () {$(this) .ready ();}) ("button") .click (function () {$("p") .unbind ();});})
This is a paragraph.
This is another paragraph.
Click on any paragraph to make it disappear. Including this paragraph.
Delete the event handler for the p element
Method 2: use the undelegate () method
The undelegate () method removes one or more event handlers added by the delegate () method.
Example:
$(document) .ready (function () {$("body") .delegate ("p", "click", function () {$(this) .ready ();}) $("button") .click (function () {$("body") .undelegate ();})
This is a paragraph.
This is another paragraph.
Click on any paragraph to make it disappear. Including this paragraph.
Delete click event
Method 3: use the off () method
The off () method is typically used to remove event handlers added by the on () method.
(document) .ready (function () {$("p") .on ("click", function () {$(this) .css ("background-color", "pink");}) ("button") .click (function () {$("p") .off ();});})
Click on this paragraph to change its background color.
Click the button and then click on this paragraph (the click event has been removed).
Remove the click event
Note: since jQuery version 1.7, the off () method is a new alternative to the unbind (), die (), and undelegate () methods. This method brings a lot of convenience to API, and we recommend it, which simplifies the jQuery code base.
At this point, I believe you have a deeper understanding of "how to remove mouse events in jquery". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.