In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "how to understand jquery bind on events". In daily operation, I believe many people have doubts about how to understand jquery bind on events. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "how to understand jquery bind on events"! Next, please follow the editor to study!
1111111111
/ / the difference between the root on of bind I think there is not much difference between bind and on.
/ / the following code test needs to comment out other code first. No, then binding events will affect the previous bound events.
/ *
* the most basic application
* if the binding method in the following 2 is added later to the new a tag under div1, the newly added a tag does not have a click event
* you can open this page and click 1111111111 console to output 1111111111.
* clicking on the newly added 222222 is unresponsive
* * /
$("body # div1 a") .bind ("click", function () {
Console.log ($(this) .html ()
});
$("body # div1 a") .on ("click", function () {
Console.log ($(this) .html ()
});
$("# div1") .append ("222222")
/ *
* enhanced version
* examples of methods that bind can pass parameters to calls are as follows
* * /
$("body # div1 a") .on ("click", "I am the parameter!" , function (data) {
/ / here the data.data attribute is I am the parameter!
Console.log (data.data)
});
/ *
* Super enhanced version
* on can add events to future tags
* what do you mean by adding an event to a future tag? for example, just entering the page, there is an a tag 1111111111. I bound the click event with on.
* after the dynamic addition of the a tag 222222, there will also be click event specific code implemented in this way.
*
* * /
$("body # div1"). On ("click", "a", function (data) {
/ / here the data.data attribute is I am the parameter!
Console.log ($(this) .html ()
});
$("# div1") .append ("222222")
/ *
* Super enhanced version
* on can add events to future tags and pass parameters
*
* * /
$("body # div1") .on ("click", "a", "I am the parameter on can also pass parameters!" , function (data) {
/ / here the data.data attribute is I am the parameter!
Console.log (data.data)
});
$("# div1") .append ("222222")
Http://www.fuke029.com
At this point, the study on "how to understand jquery bind on events" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.