HTML DOM TR คุณสมบัติ rowIndex
![อ้างอิงวัตถุ TR](/images/up.gif)
ความหมายและการใช้งาน
rowIndex คุณสมบัติส่งกลับแถว ( แถว ) ตำแหน่ง (ดัชนีแถว) ในแถวในชุดตาราง
ไวยากรณ์
กลับ rowIndex คุณสมบัติ:
trObject.rowIndex
เคล็ดลับ: คุณสมบัติ rowIndexมีค่าเริ่มต้นไม่มี
สนับสนุนเบราว์เซอร์
เบราว์เซอร์ที่สำคัญทั้งหมดสนับสนุนคุณสมบัติ rowIndex
ตัวอย่าง
ตัวอย่าง
ตัวอย่างต่อไปนี้จะส่งกลับตำแหน่งของแถวในตารางที่:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.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>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.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](/images/up.gif)