tr rowIndexProperty
tr Object
Definition and Usage
The rowIndex property returns a row (rows) in the table's row collection (row index).
Syntax
Return the rowIndex property:
trObject.rowIndex
Tip:The rowIndex property has no default value.
Browser Support
![]()
![]()
![]()
![]()
![]()
All mainstream browsers support the rowIndex property.
Example
Example
The following example returns the position of a row in the table:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example (example.com)</title>
<script>
function displayResult(x){
alert("Row index is: " + x.rowIndex);
}
</script>
</head>
<body>
<table border="1">
<tr onclick="displayResult(this)">
<td>Click to display row index</td>
</tr>
<tr onclick="displayResult(this)">
<td>Click to display row index</td>
</tr>
<tr onclick="displayResult(this)">
<td>Click to display row index</td>
</tr>
</table>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Example (example.com)</title>
<script>
function displayResult(x){
alert("Row index is: " + x.rowIndex);
}
</script>
</head>
<body>
<table border="1">
<tr onclick="displayResult(this)">
<td>Click to display row index</td>
</tr>
<tr onclick="displayResult(this)">
<td>Click to display row index</td>
</tr>
<tr onclick="displayResult(this)">
<td>Click to display row index</td>
</tr>
</table>
</body>
</html>
Try it Yourself »
tr Object Other extensions