Delete all rows in an HTML table

后端 未结 19 1760
既然无缘
既然无缘 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

    Assing some id to tbody tag. i.e. . After this, the following line should retain the table header/footer and remove all the rows.

    document.getElementById("yourID").innerHTML="";
    

    And, if you want the entire table (header/rows/footer) to wipe out, then set the id at table level i.e.

提交回复
热议问题