tr rowIndex 屬性

定義和用法
rowIndex 屬性返回某一行(rows )在表格的行集合中的位置(row index)。
語(yǔ)法
返回 rowIndex 屬性:
trObject.rowIndex
提示:rowIndex 屬性沒(méi)有默認(rèn)值。
瀏覽器支持
所有主流瀏覽器都支持 rowIndex 屬性
實(shí)例
實(shí)例
下面的例子返回了某一行在表格中的位置:
<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>
<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>
嘗試一下 ?

更多建議: