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 get tr? how many td are there in it?

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

Share

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

This article mainly introduces how to get tr from jquery. There are several td in it. It is very detailed and has some reference value. If you are interested, you must finish reading it.

There are several td methods for jquery to get tr: 1, use the "$('td')" statement to match the td element; 2, use the size () method to get the number of matching td elements, you can get the number of td elements in the tr element, the syntax is "$(' td'). Size ();".

The operating environment of this tutorial: windows7 system, jquery1.10.0 version, Dell G3 computer.

There are several ways for jquery to get td in tr.

1. Create a new html file, named test.html, to explain how jquery gets the number of td in the tr in the table. Introduce the jquery.min.js library file and load it successfully before you can use the methods in jquery. Create a two-row and two-column table using table, tr, and td tags, and set the table border to 1px.

Within the test.html file, use the button tag to create a button named "get the number of td". Bind the onclick click event to the button button, and execute the getnum () function when the button is clicked.

2, in the js tag, create the getnum () function, within the function, get the cell object of the table through the td element name, use the size () method to get the number of td in tr, and finally, use the alert () method to output the number of td.

Open the test.html file in the browser and click the button to see the obtained value.

Summary:

1. Create a test.html file.

2, in the file, use table, tr, td tags to create a two-row and two-column table, and create a button button to trigger the execution of the js function.

3. In the js tag, create a function. Within the function, by getting the td element object, you can use the size () method to get the number of td in the tr.

Matters needing attention

The size () method also applies to getting the number of tr rows.

The above is all the content of the article "how to get a few td in tr by jquery". Thank you for reading! Hope to share the content to help you, more related 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