Table deleteCaption() 方法

Table 对象参考手册 Table 对象

定义和用法

deleteCaption() 方法用于删除表格的 caption 元素及其内容。

提示: 在表格中创建新的标题请使用 createCaption() 方法。

语法

tableObject.deleteCaption()


浏览器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主要浏览器都支持 deleteCaption() 方法


实例

实例

下面的例子删除表格的标题:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本站教程(icodebang.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>

尝试一下 »


Table 对象参考手册 Table 对象

0 个评论

要回复文章请先登录注册