1. In fact, there are many versions on the Internet, tried several can not, and finally found a very convenient: will not clear the first row of the table header section.
Where J_TAB_FAM is the ID of the table.
?
1 |
$( "#J_tab_fam tr:not(:first)" ).html( "" ); |
or a
?
1 |
$( "#J_tab_fam tr:not(:first)" ).empty( "" ); |
2. Of course, there are other ways, such as getting all the rows of the table, and then for the loop setting each table value is empty, but efficiency or in terms of code, efficiency and quality is reduced, if not using the Jquery,for loop may also be a way!
3. In addition, you can get the table ChildNodes list, and then clear the need to clear the node, but because some browsers are different, resulting in childnodes when the number is different (FF browser seems to be a carriage return also as a node, really drunk ~ ~ So this approach may not be compatible, for a better compatibility, you can also add a class to each line, and then each time you clear the time to determine whether the class is the classname you want to delete, is deleted.
In short, recommend the first kind!!!
jquery implements emptying table table all data except the first row