Propriété tBodies

La propriété tBodies stocke un tableau de tous les tbody du tableau (il peut y en avoir plusieurs).

Syntaxe

javascripttable.tBodies;

Exemple

Obtenons et parcourons en boucle tous les tbody du tableau :

html<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>
javascriptlet table = document.querySelector('#table');

for (let tBody of table.tBodies) {
  console.log(tBody);
}

Voir aussi

  • la propriété tHead,
    qui contient le thead du tableau
  • la propriété tFoot,
    qui contient le tfoot du tableau
  • la propriété rows,
    qui contient les lignes du tableau
  • la propriété cells,
    qui contient les cellules du tableau