方法一:

var artTable = document.getElementById("artical_table");

console.debug(artTable.getElementsByTagName("thead")[0]);

var artBody=artTable.tBodies[0];

//clear table

//artBody.innerHTML='';

//获取tbody,清除innerHTML来达到清除表格数据,会报错

artBody.parentNode.outerHTML = artBody.parentNode.outerHTML.replace(artBody.innerHTML, "");

//解决tbody的innerHTML只读问题,这种也会有问题,会导致后面动态插入的行没有

方法二:

$('table tbody').empty();
$('table tr').empty();

javascript清除table表格方法

相关文章:

  • 2022-12-23
  • 2021-12-30
  • 2021-07-28
  • 2021-10-30
  • 2022-12-23
  • 2021-06-16
  • 2021-10-18
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-05-19
  • 2021-09-03
  • 2021-10-14
  • 2022-12-23
  • 2021-11-20
相关资源
相似解决方案