คุณสมบัติ tBodies

คุณสมบัติ tBodies เก็บอาร์เรย์ของ tbody ทั้งหมดของตาราง (อาจมีได้หลายตัว)

ไวยากรณ์

javascriptตาราง.tBodies;

ตัวอย่าง

รับและวนลูปผ่าน tbody ทั้งหมดของตาราง:

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

ดูเพิ่มเติม

  • คุณสมบัติ tHead,
    ซึ่งเก็บ thead ของตาราง
  • คุณสมบัติ tFoot,
    ซึ่งเก็บ tfoot ของตาราง
  • คุณสมบัติ rows,
    ซึ่งเก็บแถวของตาราง
  • คุณสมบัติ cells,
    ซึ่งเก็บเซลล์ของตาราง