tr rowIndex 屬性

tr 對象參考手冊 tr 對象

定義和用法

rowIndex 屬性返回某一行(rows )在表格的行集合中的位置(row index)。

語法

返回 rowIndex 屬性:

trObject.rowIndex

提示:rowIndex 屬性沒有默認值。


流覽器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主流流覽器都支持 rowIndex 屬性


實例

實例

下麵的例子返回了某一行在表格中的位置:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>IT研修(xuhuhu.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>



tr 對象參考手冊 tr 對象