HTML DOM caption 屬性
定義和用法
caption 屬性設置或返回表格的 caption 元素。
<caption> 元素定義了一個表格標題。<caption> 標簽必須緊跟在 <table> 標簽之后,每個表格僅能規(guī)定一個 caption。通常,caption 會位于表格之上居中的位置。
語法
tableObject.caption=captionObject
實例
下面的例子可返回表格的 <caption> 元素的文本:
<html>
<head>
<script type="text/javascript">
function alertCaption()
{
alert(document.getElementById("table1").caption.innerHTML
);
}
</script>
</head>
<body>
<table id="table1" border="1">
<caption>This is a table caption</caption>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>Peter</td>
<td>Griffin</td>
</tr>
</table>
<br />
<input type="button" onclick=alertCaption()
value="Alert table caption" />
</body>
</html>