<!DOCTYPE html><html><head><title>test</title>? <meta http-equiv="Content-Type" content="text/html; charset=gbk"/><script type="text/javascript">function deleteRow(r)? {? var i=r.parentNode.parentNode.rowIndex;? document.getElementById('myTable').deleteRow(i);? document.getElementById("in").value=i;? }</script></head><body><table id="myTable" border="1"><tr>? <td>Row 1</td>? <td><input type="button" value="刪除" onclick="deleteRow(this)"></td></tr><tr>? <td>Row 2</td>? <td><input type="button" value="刪除" onclick="deleteRow(this)"></td></tr><tr>? <td>Row 3</td>? <td><input type="button" value="刪除" onclick="deleteRow(this)"></td></tr></table><input type="text" id="in"></body></html>方法中var i=r.parentNode.parentNode.rowIndex;為什么i可以得到r對應行的序號,和rowIndex的實現機制有關么?r.parentNode.parentNode得到的是table節點,table節點的rowIndex得到的是什么?
rowIndex的問題
qq_甘蔗_0
2015-11-23 21:18:57