Latest web development tutorials

HTML DOM td/th cellIndex 屬性

td/th 對象參考手冊 td/th對象

定義和用法

cellIndex 屬性可返回一行的單元格集合中單元格的位置。

語法

返回cellIndex 屬性:

tdObject.cellIndex

或者

thObject.cellIndex

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


瀏覽器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主流瀏覽器都支持cellIndex 屬性


實例

實例

彈出單元格的位置(cellIndex):

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.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 對象參考手冊 td/th對象