In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you jquery how to judge which element is clicked, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Methods: 1, use the bind () method to bind the click event to the element and specify an event handler function; 2, in the handling function, use the index () method to calculate the index position of the click element, the syntax is "$(element object). Bind ('click',function () {element object .index ();})".
The operating environment of this tutorial: windows7 system, jquery3.2.1 version, Dell G3 computer.
In jquery, you can use the index () method to get the element of the current click. The following example explains how to use jquery to know which li I clicked on.
Examples are as follows:
1. Create a new html file, named test.html, to explain how to use jquery to know which li I clicked on. Load the jquery.min.js file using the script tag, and load the file successfully before you can use the jquery method. Use the ul tag, the li tag to create a list, for example, to create three project lists. Use the ready () method to execute the function method when the page is loaded.
2. In the function method, by getting the li object, use the bind () method to bind the click click event to each li. When the li is clicked, use the index () method to get the index value of the current li tag. Finally, use the alert () method to output the index value.
Open the test.html file in the browser and click the button to view the results.
1. Use the bind () method to bind a click click event to each li tag.
2. Get the location index of the current click on the li tag through the index () method.
Note:
The index obtained by index () starts at 0, so the above example adds 1.
The above is all the contents of the article "how to tell which element jquery clicked". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, 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.
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.