Search w3schools.com:

SHARE THIS PAGE

tr rowIndex Property

tr Object Reference tr Object

Definition and Usage

The rowIndex property returns the position of a row in the rows collection of a table.

Syntax

Return the rowIndex property:

trObject.rowIndex

Tip: There is no default value for the rowIndex property.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The rowIndex property is supported in all major browsers.


Example

Example

Alert the position of the rows in the table's rows collection:

<html>
<head>
<script>
function displayResult(x)
{
alert("Row index is: " + x.rowIndex);
}
</script>
</head>
<body>

<table border="1">
  <tr onclick="displayResult(this)">
    <td>Click to show rowIndex</td>
  </tr>
  <tr onclick="displayResult(this)">
    <td>Click to show rowIndex</td>
  </tr>
  <tr onclick="displayResult(this)">
    <td>Click to show rowIndex</td>
  </tr>
</table>

</body>
</html>

Try it yourself »


tr Object Reference tr Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]