Home > Web Front-end > JS Tutorial > body text

How to hide the tr of table in jquery

WBOY
Release: 2021-11-16 14:41:22
Original
2475 people have browsed it

Jquery method to hide tr in table: 1. Use the "$(".tr class name")" statement to obtain the object according to the specified class value; 2. Use the hide() method to hide the obtained object , the syntax is "$(".tr class name").hide();".

How to hide the tr of table in jquery

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

How jquery hides tr in table

1. Create a new html file and name it test.html to explain how jquery determines Whether the element is visible. In the test.html file, use the table, tr, and td tags to create a table with six rows and two columns. To facilitate viewing, set a 1px border for the table. In the test.html file, in the table table, set the class attribute of part of tr to aa, and set the id of the last row to bb.

In the test.html file, use the button tag to create two buttons, namely "Hide tr" and "Show tr". The code is as follows:

How to hide the tr of table in jquery

2. In the test.html file, bind onclick events to the two button buttons respectively. When the buttons are clicked, the "hiddentr()" function and the "displaytr()" function are executed respectively.

In the js tag, create the hiddentr() function and the displaytr() function. In the hiddentr() function, obtain the tr row object with class aa. Use the hide() method to hide tr. In displaytr( ) function, obtain the tr row object with id bb, and use the show() method to display tr.

How to hide the tr of table in jquery

Open the test.html file in the browser and click on the buttons to see the effect.

How to hide the tr of table in jquery

After clicking to hide tr

How to hide the tr of table in jquery

Create a test.html file. Within the file, use the table, tr, and td tags to create a table with six rows and two columns. Create two button buttons at the same time to trigger the execution of js functions. In the js tag, create the hiddentr() function and the displaytr() function. In the hiddentr() function, obtain the tr row object with class aa. Use the hide() method to hide tr. In the displaytr() function, obtain the id. For the tr row object of bb, use the show() method to display tr.

For more programming related knowledge, please visit: Programming Video! !

The above is the detailed content of How to hide the tr of table in jquery. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!