Name

TableRow — a <tr> element in an HTML table

Inherits from

Node, Element

Synopsis

A TableRow object represents a row (a <tr> element) in an HTML table and defines properties and methods for working with the TableCell elements of the row.

Properties

readonly HTMLCollection cells

An array-like object of TableCell objects representing the <td> and <th> elements in this row.

readonly long rowIndex

The index of this row in the table.

readonly long sectionRowIndex

The position of this row within its section (i.e., within the <thead>, <tbody>, or <tfoot> in which it is contained).

Methods

void deleteCell(long index)

This method deletes the cell at the specified index in the row.

Element insertCell([long index])

This method creates a new <td> element, inserts it into the row at the specified position, and then returns it. The new cell is inserted immediately before the cell that is currently at the position specified by index. If index is omitted, is -1, or is equal to the number of cells in the row, the new cell is appended to the end of the row.

Note that this convenience method inserts <td> data cells only. If you need to add a header cell into a row, you must create and insert the <th> element using Document.create Element() and Node.insertBefore() or related methods.

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.