tBodies property

The tBodies property stores an array of all tbody's of a tables (there may be more than one).

Syntax

javascripttable.tBodies;

Example

Get and loop through all tbody's of a table:

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);
}

See also

  • the tHead property
    that contains thead of a table
  • the tFoot property
    that contains tfoot of a table
  • the rows property
    that contains rows of a table
  • the cells property
    that contains table cells