Home > Web Front-end > JS Tutorial > How to clear the table using javascript_javascript skills

How to clear the table using javascript_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 15:59:06
Original
2706 people have browsed it

The example in this article describes how to clear the table using javascript. Share it with everyone for your reference. The details are as follows:

1. Normal method

Loop through the rows of the table and delete them one by one.
This method is a common method and is feasible, but it is not efficient.

2. Another method

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只读问题,这种也会有问题,会导致后面动态插入的行没有
Copy after login

I hope this article will be helpful to everyone’s JavaScript programming design.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
What are JavaScript hook functions?
From 1970-01-01 08:00:00
0
0
0
What is JavaScript garbage collection?
From 1970-01-01 08:00:00
0
0
0
c++ calls javascript
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template