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

sectionRowIndex property (tr)

Browser support:
Returns the position of a row in the rows collection of a tbody, thead or tfoot element.
This property is similar to the rowIndex 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.

Syntax:

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

Possible values:

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

Example HTML code 1:

This example illustrates the use of the sectionRowIndex property:
<head>
    <script type="text/javascript">
        function OnRowClick (row) {
            alert ("Index in the table: " + row.rowIndex + 
                   "\nIndex in the section: " + row.sectionRowIndex);
        }
    </script>
</head>
<body>
    Click on the rows of the table!<br /><br />
    <table border="1px">
        <thead>
            <tr onclick="OnRowClick (this)">
                <th>Fruit</th> 
                <th>Cost per kilo</th>
            </tr>
        </thead>
        <tbody>
            <tr onclick="OnRowClick (this)">
                <td>Apple</td>
                <td>$5</td>
            </tr>
            <tr onclick="OnRowClick (this)">
                <td>Pear</td>
                <td>$10.50</td>
            </tr>
            <tr onclick="OnRowClick (this)">
                <td>Peach</td>
                <td>$23.30</td>
            </tr>
        </tbody>
        <tfoot>
            <tr onclick="OnRowClick (this)">
                <td></td>
                <td>$38.80</td>
            </tr>
        </tfoot>
    </table>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content