Delete all rows in an HTML table

后端 未结 19 1765
既然无缘
既然无缘 2020-12-04 12:03

How can I delete all rows of an HTML table except the \'s using Javascript, and without looping through all the rows in the table? I have a very huge

19条回答
  •  渐次进展
    2020-12-04 12:22

    This works in IE without even having to declare a var for the table and will delete all rows:

    for(var i = 0; i < resultsTable.rows.length;)
    {   
       resultsTable.deleteRow(i);
    }
    

提交回复
热议问题