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 query which tr the current element is?

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

Share

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

The main content of this article is to explain "jquery how to query the current element is which tr", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "jquery how to query the current element is which tr" it!

Methods: 1, use the "$(this)" statement and index () method to obtain the index position of the current tr element, and then get the number of the current element, the syntax is "$(this). Index () + 1;"; 2, use the alert () method to output the number of current element positions.

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

How does jquery query which tr the current element is?

We can query the number of tr of the current element through the index () method.

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

These elements can be specified through jQuery selectors or DOM elements.

Note: if no element is found, index () returns-1.

Examples are as follows:

$(function () {("table tr") .click (function () {var col = $(this). Index () + 1; / column location alert ("current location: + col+" tr ")});}); 1234 2456 3789 4123

Output result:

When you click on the second line of elements, output the result:

At this point, I believe you have a deeper understanding of "jquery how to query the current element is the number of tr", might as well to the actual operation of it! 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.

Share To

Development

Wechat

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

12
Report