HTMLTableElement: rows property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

The rows read-only property of the HTMLTableElement interface returns a live HTMLCollection of all <tr> elements that are a child of the given <table> element, or a child of one of the table's <thead>, <tbody>, and <tfoot> children. The members of the <thead> appear first, followed by members of the <tbody> and the table itself, and members of the <tfoot> come last, sorted by tree order within each group.

Although the property is read-only, the returned object is live and is automatically updated when the HTMLTableElement changes.

Value

A live HTMLCollection of HTMLTableRowElement objects.

Examples

js
const myRows = myTable.rows;
const firstRow = myTable.rows[0];
const lastRow = myTable.rows.item(myTable.rows.length - 1);

This demonstrates how you can use both indexed access and the HTMLCollection.item() method to obtain individual rows in the table.

Specifications

Specification
HTML
# dom-table-rows-dev

Browser compatibility

See also