X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

TableRow rowIndex Property

TableRow Object Reference TableRow Object

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

Internet Explorer Firefox Opera Google Chrome Safari

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>";
}
document.getElementById("demo").innerHTML = txt;

Try it yourself »


TableRow Object Reference TableRow Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook