Home >Web Front-end >JS Tutorial >Javascript operation table (detailed explanation of insertRow, deleteRow, insertCell, deleteCell method)_javascript skills
insertRow() method
Definition and usage
The insertRow() method is used to insert a new row at the specified position in the table.
Grammar
tableObject.insertRow(index)
Return value
Returns a TableRow representing the newly inserted row.
Description
This method creates a new TableRow object, representing a new
The new row will be inserted before the row at index. If index is equal to the number of rows in the table, new rows will be appended to the end of the table.
If the table is empty, the new row will be inserted into a new
Throws
If the parameter index is less than 0 or greater than or equal to the number of rows in the table, this method will throw a DOMException exception with code INDEX_SIZE_ERR.
Example
Row1 cell1 | |
Row2 cell1 | Row2 cell2 |