You are here: Reference > JavaScript > client-side > HTML DOM > properties > rowIndex (tr)

rowIndex property (tr)

Browser support:
Returns the position of a row in the rows collection of the table.
This property is similar to the sectionRowIndex property. The rowIndex property retrieves the position of a row in the entire table, while the sectionRowIndex property retrieves the position in the section that contains the row.


You can find the related objects in the Supported by objects section below.
This property is read-only.

Possible values:

Zero-based Integer that represents the position of the row.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the rowIndex property:
    <script type="text/javascript">
        function OnRowClick (row) {
            alert ("Index in the table: " + row.rowIndex + 
                   "\nIndex in the section: " + row.sectionRowIndex);
    Click on the rows of the table!<br /><br />
    <table border="1px">
            <tr onclick="OnRowClick (this)">
                <th>Cost per kilo</th>
            <tr onclick="OnRowClick (this)">
            <tr onclick="OnRowClick (this)">
            <tr onclick="OnRowClick (this)">
            <tr onclick="OnRowClick (this)">
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content