Name

Table — an HTML <table>

Inherits from

Node, Element

Synopsis

The Table object represents an HTML <table> element and defines a number of convenience properties and methods for querying and modifying various sections of the table. These methods and properties make it easier to work with tables, but their functionality can also be duplicated with core DOM methods.

HTML tables are composed of sections, rows, and cells. See TableCell, TableRow, and TableSection.

Properties

In addition to the properties listed here, Table elements also have a summary property that mirrors the HTML attribute of the same name.

Element caption

A reference to the <caption> element for the table, or null if there is none

readonly HTMLCollection rows

An array-like object of TableRow objects that represent all the rows in the table. This includes all rows defined within <thead>, <tfoot>, and <tbody> tags.

readonly HTMLCollection tBodies

An array-like object of TableSection objects that represent all the <tbody> sections in this table.

TableSection tFoot

The <tfoot> element of the table, or null if there is none.

TableSection tHead

The <thead> element of the table, or null if there is none.

Methods

Element createCaption()

This method returns an Element object representing the <caption> of this table. If the table already has a caption, this method simply returns it. If the table does not have an existing <caption>, this method creates a new (empty) caption and inserts it into the table before returning it.

TableSection createTBody ...

Get JavaScript: The Definitive Guide, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.