Delete all rows in an HTML table

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

    If you can declare an ID for tbody you can simply run this function:

    var node = document.getElementById("tablebody");
    while (node.hasChildNodes()) {
      node.removeChild(node.lastChild);
    }
    
    0 讨论(0)
提交回复
热议问题