Table deleteCaption() 方法

定义和用法
deleteCaption() 方法用于删除表格的 caption 元素及其内容。
提示: 在表格中创建新的标题请使用createCaption() 方法。
语法
tableObject.deleteCaption()
浏览器支持
所有主要浏览器都支持 deleteCaption() 方法
实例
实例
下面的例子删除表格的标题:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>小鸟启蒙(facesoho.com)</title>
<script>
function displayResult(){
document.getElementById("myTable").deleteCaption();
}
</script>
</head>
<body>
<table id="myTable" border="1">
<caption>这是个表格标题</caption>
<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="displayResult()">删除标题</button>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title>小鸟启蒙(facesoho.com)</title>
<script>
function displayResult(){
document.getElementById("myTable").deleteCaption();
}
</script>
</head>
<body>
<table id="myTable" border="1">
<caption>这是个表格标题</caption>
<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="displayResult()">删除标题</button>
</body>
</html>
尝试一下 »

尊贵的董事大人
英文标题不为空时 视为本栏投稿
需要关键字 描述 英文标题