Example
Click on different rows to alert their index position:
alert("Row index is: " + x.rowIndex);
Try it Yourself »
Definition and Usage
The rowIndex property returns the position of a row in the rows collection of a table.
Browser Support
The rowIndex property is supported in all major browsers.
Syntax
Return the rowIndex property:
tablerowObject.rowIndex
Technical Details
Return Value: | A Number, representing the position of the row in the rows collection of a table |
---|
More Examples
Example
Return the index position of each row in a 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 »
< TableRow Object