TableRow rowIndex Property

Definition and Usage

rowIndex Property returns the rowIndex of the row in the table rows Collection Location.

See also:

HTML Reference Manual:HTML <tr> Tag

Instance

Example 1

Click on different rows to output their index positions:

alert("Row index is: " + x.rowIndex);

Try It Yourself

Example 2

Return the index position of each row in the table:

var x = document.getElementsByTagName("tr");
var txt = "";
var i;
for (i = 0; i < x.length; i++) {
  txt = txt + "The index of Row "+(i+1)+" is: "+x[i].rowIndex+"<br>";
}

Try It Yourself

Syntax

Returns rowIndex property:

tablerowObject.rowIndex

Technical Details

Return Value: A number representing the row's position in the table. rows Collection Location.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support