<!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對(duì)應(yīng)行的序號(hào),和rowIndex的實(shí)現(xiàn)機(jī)制有關(guān)么?r.parentNode.parentNode得到的是table節(jié)點(diǎn),table節(jié)點(diǎn)的rowIndex得到的是什么?
rowIndex的問(wèn)題
qq_甘蔗_0
2015-11-23 21:18:57