HTML DOM Table propriété caption
Définition et utilisation
propriété caption retourne un élément table de légende.
élément de légende définit les en-têtes de table.
Note: <caption> définit un en- tête de table.Balise <caption> doit être immédiatement après la balise <table>, chaque table ne peut spécifier une légende. Typiquement, la légende sera situé au-dessus du centre de la position de la table.
grammaire
tableObject.caption
support du navigateur
Tous les principaux navigateurs prennent en charge la propriété de légende
Exemples
Exemples
L'exemple suivant renvoie l'élément forme <caption> du texte:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.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>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.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>
Essayez »
Table Object