Propriété tBodies
La propriété tBodies stocke un tableau de tous les
tbody
du tableau (il peut y en avoir plusieurs).
Syntaxe
table.tBodies;
Exemple
Obtenons et parcourons en boucle tous les tbody du tableau :
<table id="table">
<thead>
<tr>
<th>header1</th>
<th>header2</th>
<th>header3</th>
</tr>
</thead>
<tbody>
<tr>
<td>value</td>
<td>value</td>
<td>value</td>
</tr>
<tr>
<td>value</td>
<td>value</td>
<td>value</td>
</tr>
</tbody>
<tbody>
<tr>
<td>value</td>
<td>value</td>
<td>value</td>
</tr>
<tr>
<td>value</td>
<td>value</td>
<td>value</td>
</tr>
</tbody>
</table>
let table = document.querySelector('#table');
for (let tBody of table.tBodies) {
console.log(tBody);
}