Latest web development tutorials

HTML DOM tr rowIndex property

tr Object Reference tr objects

Definition and Usage

rowIndex property returns a row ( rows ) position (row index) in a row in the table set.

grammar

Back rowIndex properties:

trObject.rowIndex

Tip: rowIndex property has no default value.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support rowIndex property


Examples

Examples

The following example returns the position of a row in the table:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult(x){
    alert("Row index is: " + x.rowIndex);
}
</script>
</head>
<body>

<table border="1">
    <tr onclick="displayResult(this)">
        <td>单击显示行下标</td>
    </tr>
    <tr onclick="displayResult(this)">
    <td>单击显示行下标</td>
    </tr>
    <tr onclick="displayResult(this)">
    <td>单击显示行下标</td>
    </tr>
</table>

</body>
</html>

try it"


tr Object Reference tr objects