/

HTML / CSS / JavaScript Tutorial

JavaScript table object method: insertRow()

[this page | pdf | back links]

The insertRow() method of the JavaScript DOM object corresponding to the HTML <table> element creates an empty <tr> element and adds it to the table.

 

It has the following syntax with the following parameters:

 

object.insertRow(index)

 

Parameter

Required / Optional

Description

index

Required (see below)

Index position where row is to be inserted (index starts at 0). Using zero sometimes inserts a new row at the start and sometimes at the end depending on browser. Using -1 inserts after the end of the existing last row.

 

Note: the index parameter is required by some browsers but optional for others.

 


NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)


Desktop view | Switch to Mobile