คุณสมบัติ tHead

คุณสมบัติ tHead เก็บลิงก์ไปยัง thead ของตาราง

ไวยากรณ์

javascriptตาราง.tHead;

ตัวอย่าง

มาทาสีส่วนหัวตารางให้เป็นสีแดง:

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>
  <tfoot>
    <tr>
      <td>ผลรวม</td>
      <td>ผลรวม</td>
      <td>ผลรวม</td>
    </tr>
  </tfoot>
</table>
javascriptlet table = document.querySelector('#table');
table.tHead.style.color = 'red';

ดูเพิ่มเติม

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