How to clear the table except the first two rows in jquery

青灯夜游
Release: 2022-04-22 18:09:59
Original
2362 people have browsed it

Jquery method to clear the table except the first two rows: 1. Use the "$("tr:first").empty();" statement to select the first row of the table and clear the content of the row; 2. Use The "$("tr:nth-child(2)").empty();" statement selects the second row of the table and clears the content of the row.

How to clear the table except the first two rows in jquery

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

jquery clears the table except the first two rows

Implementation method:

  • Use the:firstselector to select the first row of the table, and use empty() to clear the content

  • Use:nth-child(2)The selector selects the second row of the table and uses empty() to clear the content

Description: The empty() method can remove all child nodes and content of the selected element.

Implementation code:

      
商品 价格
T恤 ¥100
牛仔褂 ¥250
牛仔库 ¥150

Copy after login

How to clear the table except the first two rows in jquery

[Recommended learning:jQuery video tutorial,web Front-End Video

The above is the detailed content of How to clear the table except the first two rows 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 Recommendations
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!