HTML DOM Table caption Property
-- Learning not just technology, but also dreams!
Table caption Property
Table Object
Definition and Usage
The caption property returns the <caption> element of a table.
The <caption> element defines the title of the table.
Note: The <caption> element defines a table title. The <caption> tag must come immediately after the <table> tag, and each table can have only one <caption>. Typically, the caption is positioned centered above the table.
Syntax
tableObject.caption
Browser Support
All major browsers support the caption property.
Example
The following example returns the text of the <caption> element in a table:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title> ()</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()">Display the number of tbody elements in the table</button>
</body>
</html>
Coding Plans
Byte Ark Coding Plan
Supports mainstream large models such as Doubao, GLM, DeepSeek, Kimi, MiniMax, official direct supply, stable and reliable.
Β₯9.9 / month
Start NowXunfei Xingchen Coding Plan
Includes free model call quota, supports DeepSeek, GLM, Kimi, MiniMax β an all-in-one experience and deployment platform.
Β₯3.9 / month
Start Now
YouTip