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>初心者チュートリアル(example.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 オブジェクト その他の拡張