Table caption 属性

Table 对象参考手册 Table 对象

定义和用法

caption 属性返回了表格的 caption 元素。

caption 元素定义了表格的标题。

注意: <caption> 元素定义了一个表格标题。<caption> 标签必须紧跟在 <table> 标签之后,每个表格仅能规定一个 caption。通常,caption 会位于表格之上居中的位置。

语法

tableObject.caption


浏览器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主要浏览器都支持 caption 属性


实例

实例

下面的例子可返回表格的 <caption> 元素的文本:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本站教程(icodebang.com)</title>
<script>
function displayResult(){
    alert(document.getElementById("myTable").tBodies.length);
}
</script>
</head>
<body>

<table id="myTable" border="1">
<tbody>
    <tr>
        <td>cell 1</td>
        <td>cell 2</td>
    </tr>
</tbody>
<tbody>
<tr>
        <td>cell 3</td>
        <td>cell 4</td>
</tr>
</tbody>
</table>
<br>
<button type="button" onclick="displayResult()">显示表中 tbody 元素的数目</button>

</body>
</html>

尝试一下 »


Table 对象参考手册 Table 对象

0 个评论

要回复文章请先登录注册