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.
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:first
selector 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:
[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!