JavaScript: The Definitive Guide

25.270. Table.insertRow( ): add a new, empty row to the table

DOM Level 2 HTML

25.270.1. Synopsis

HTMLElement insertRow(long index) tHRows DOMException;

25.270.1.1. Arguments

index

The position at which the new row is to be inserted.

25.270.1.2. Returns

A TableRow that represents the newly inserted row.

25.270.1.3. Throws

This method throws a DOMException with a code of INDEX_SIZE_ERR if index is less than zero or greater than the number of rows in the table.

25.270.2. Description

This method creates a new TableRow representing a <tr> tag and inserts it into the table at the specified position.

The new row is inserted in the same section and immediately before the existing row at the position specified by index. If index is equal to the number of rows in the table, the new row is appended to the last section of the table. If the table is initially empty, the new row is inserted into a new <tbody> section that is itself inserted into the table.

You can use the convenience method TableRow.insertCell( ) to add content to the newly created row.

25.270.3. See Also

TableSection.insertRow( )

Категории