本文主要分享一下原生javascript清空table表格的方法,仅供参考:
let table = document.getElementById("tableId");
var len = table.childNodes.length;
for (let i = len-1; i >=0; i--) {
table.removeChild(table.childNodes[i]);
}
删除时会改变node节点的索引
采用倒序删除即可解决
标签:原生,表格,javascript,清空,table,childNodes From: https://www.cnblogs.com/lichuanjiang/p/16858123.html