MDN self-hosted library · e01.org

HTMLTableElement: rows property

HTML DOM

Open notebook · 1 cells web-api-instance-property upstream source

HTML DOM

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

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

Browser compatibility

See also

  • HTMLTableElement.insertRow()
  • HTMLTableElement.deleteRow()