JavaScript Reference/Javascript Methods/createCaption
"createCaption()" Example
<html>
<body>
<script language="JavaScript">
function function1() {
var myC = document.getElementById("myTable").createCaption();
myC.innerText = "This is the new caption text";
}
</script>
<table id="myTable" border="3" cellpadding="5" style="border-color:blue">
<tr>
<th>This table has no caption</th>
</tr>
</table>
<input type="button" value="Add caption" onclick="function1();">
</body>
</html>
"createCaption()" is applied to
+----------------+--------------------------------------------------------------+
| Applied_To |<table> |
+----------------+--------------------------------------------------------------+
"createCaption()" Syntax, Parameters and Note
Note:
Creates a <caption> element associated with the specified table.
The contents of the <caption> must also be set at run time.
Syntax:
document.getElementById("tableID").createCaption()
document.all.tableID.createCaption() // IE only