In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
In this article, the editor introduces in detail "how to bind jquery events". The content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to bind jquery events" can help you solve your doubts.
1. Bind ()
Bing () is used to bind events, for example:
2. Unbind ()
Unbind () is used to unbind the event. For example:
3. On ()
The on () method is used to bind events, such as:
4. Off ()
The off () method is used to unbind an event, for example:
Note:
It is recommended to bind events with the on () method, which is more efficient.
5. Example event binding $(function () {/ / normally the mouse moves into the background color to become gray Turns white when removed / / mouse moves in / * $("# menu li") .Mouseover (function () {$(this) .css ("background-color", "gray")) }); / / move the mouse out of $("# menu li") .mouseout (function () {$(this) .css ("background-color", "white");}) * / bind () bind event $("# menu li") .bind ("mouseover", function () {$(this) .css ("background-color", "gray");}) ("# menu li") .bind ("mouseout", function () {$(this) .css ("background-color", "white");}) / / bind () bind multiple events / * $("# menu li") .bind ("click mouseover", function () {$(this) .css ("background-color", "gray");}) * / bind () bind multiple events / * $("# menu li") .bind ({click:function () {$(this) .css ("background-color", "# ccc");}, mouseover:function () {$(this) .css ("background-color", "yellow");}}) * / / unbind event / / $("# menu li"). Unbind (); / / unbind all events / / $("# menu li") .unbind ("click") / / only release click event, leave mouse move event / / on () bind event / / handle adding background color effect $("# menu") .on ("mouseover", "li", {}, function () {$(this) .css ("background-color", "# ccc");}) $("# menu"). On ("mouseout", "li", {}, function () {$(this) .css ("background-color", "yellow");}); / / off () unbind $("# menu") .off ("mouseout", "li"); / / remove only moustout events}) HTML XHTML CSS has finished reading this article "how to bind jquery events". If you want to master the knowledge of this article, you still need to practice and use it. If you want to know more about related articles, you are welcome to follow the industry information channel.
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.