deletethead()
Table deleteTHead() 方法
定义和用法
<deleteTHead() 方法用于从表格删除 <thead> 元素。
提示: 在表格中创建 thead 元素请使用 createTHead() 方法。
语法
tableObject.deleteTHead()
浏览器支持
所有主要浏览器都支持 deleteTHead() 方法
实例
创建和删除 thead 元素:
<html>
<head>
<script>
function createTHead()
{
var x=document.getElementById("myTable");
if (!x.tHead)
{
var header=x.createTHead();
var row=header.insertRow(0);
var cell=row.insertCell(0);
cell.innerHTML="<b>This is a table header</b>";
}
}
function deleteTHead()
{
document.getElementById("myTable").deleteTHead();
}
</script>
</head>
<body>
<table id="myTable" border="1">
<tr>
<td>cell 1</td>
<td>cell 2</td>
</tr>
<tr>
<td>cell 3</td>
<td>cell 4</td>
</tr>
</table>
<br>
<button type="button" onclick="createTHead()">Create thead</button>
<button type="button" onclick="deleteTHead()">Delete thead</button>
</body>
</html>
<head>
<script>
function createTHead()
{
var x=document.getElementById("myTable");
if (!x.tHead)
{
var header=x.createTHead();
var row=header.insertRow(0);
var cell=row.insertCell(0);
cell.innerHTML="<b>This is a table header</b>";
}
}
function deleteTHead()
{
document.getElementById("myTable").deleteTHead();
}
</script>
</head>
<body>
<table id="myTable" border="1">
<tr>
<td>cell 1</td>
<td>cell 2</td>
</tr>
<tr>
<td>cell 3</td>
<td>cell 4</td>
</tr>
</table>
<br>
<button type="button" onclick="createTHead()">Create thead</button>
<button type="button" onclick="deleteTHead()">Delete thead</button>
</body>
</html>