td/th cellIndexプロパティ
td/th オブジェクト
定義と使い方
cellIndex プロパティは、1行のセル集合内でのセルの位置を返します。
構文
cellIndex プロパティを返す:
tdObject.cellIndex
または
thObject.cellIndex
または
thObject.cellIndex
ヒント:cellIndex プロパティにはデフォルト値はありません。
ブラウザサポート
![]()
![]()
![]()
![]()
![]()
すべての主要ブラウザは cellIndex プロパティをサポートしています。
例
例
セルの位置(cellIndex)をポップアップ表示:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
<script>
function displayResult(x){
alert("Cell index is: " + x.cellIndex);
}
</script>
</head>
<body>
<table border="1">
<tr>
<td onclick="displayResult(this)">クリックしてセルインデックスを表示</td>
<td onclick="displayResult(this)">クリックしてセルインデックスを表示</td>
</tr>
</table>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
<script>
function displayResult(x){
alert("Cell index is: " + x.cellIndex);
}
</script>
</head>
<body>
<table border="1">
<tr>
<td onclick="displayResult(this)">クリックしてセルインデックスを表示</td>
<td onclick="displayResult(this)">クリックしてセルインデックスを表示</td>
</tr>
</table>
</body>
</html>
試してみる »
td/th オブジェクト その他の拡張