JQuery clears all data in the table except the first row
1. In fact, there are many versions on the Internet. I tried several of them but I found it very convenient: I will not clear the header of the first row of the table.
J_tab_fam indicates the table id.
$ ("# J_tab_fam tr: not (: first)" pai.html ("");
Or
$ ("# J_tab_fam tr: not (: first)"). empty ("");
2. of course, there are other methods, such as getting all rows in the table, and then setting each table value as null in the for loop, but efficiency and quality are reduced in terms of code or efficiency, if jQuery is not used, the for loop may also be a way!
3. in addition, you can obtain the list of table childNodes and then clear the node to be cleared. However, when some browsers are different, the number is different (FF browser seems to regard the carriage return as a node, It's really drunk ~~) Therefore, this method may have poor compatibility. For better compatibility, you can add a class to each row, and check whether the class is the classname you want to delete each time you clear it, yes. Delete it.
In short, the first type is recommended !!!!