jquery - fastest way to remove all rows from a very large table

前端 未结 8 639
臣服心动
臣服心动 2021-01-30 09:40

I thought this might be a fast way to remove the contents of a very large table (3000 rows):

$jq(\"tbody\", myTable).remove();

But it\'s taking

8条回答
  •  暖寄归人
    2021-01-30 10:26

    You could try this...

    var myTable= document.getElementById("myTable");
    if(myTable== null)
        return;
    var oTBody = myTable.getElementsByTagName("TBODY")[0];
    if(oTBody== null)
        return;
    try
    {
        oTBody.innerHTML = "";
    }
    catch(e)
    {
        for(var i=0, j=myTable.rows.length; i

提交回复
热议问题