Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does jquery determine whether tr is selected in table

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Editor to share with you how jquery determines whether tr is selected in table, I believe most people do not know much about it, so share this article for your reference. I hope you will learn a lot after reading this article. Let's learn about it together.

Methods: 1, use the click () method to bind the click event to the tr element and specify an event handling function; 2, in the event handling function, use the "$(selector) .index (element)" statement to determine whether the specified element is selected and output the location of the selected element.

The operating environment of this tutorial: windows7 system, jquery3.2.1 version, Dell G3 computer.

We can determine whether the tr element is selected by the click () method and the index () method.

The click () method indicates that a click event occurs when an element is clicked. When the mouse pointer hovers over the element and then the left mouse button is pressed and released, a click,click () method triggers the click event or specifies the function to run when the click event occurs.

The index () method returns the index position of the specified element relative to other specified elements.

Examples are as follows:

(function () {var myRows = $('table tr') .click (function () {alert (' Row #'+ myRows.index (this));}); 0-10-21-11-2 2-12-2 3-2 4-14-2

Output result:

When the first row is selected, the result is output:

The above is all the contents of the article "how jquery determines whether tr is selected in table". 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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report