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

前端 未结 8 637
臣服心动
臣服心动 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:25

    if you want to remove only fast.. you can do like below..

    $( "#tableId tbody tr" ).each( function(){
      this.parentNode.removeChild( this ); 
    });
    

    but, there can be some event-binded elements in table,

    in that case,

    above code is not prevent memory leak in IE... T-T and not fast in FF...

    sorry....

提交回复
热议问题