table中取得各个单元格中的数据-- parentElement children

function test(e)
  {
    var tt = e.parentElement.parentElement.cells[1].innerText; //11
    alert(tt);
    
    var _array = e.parentElement.parentElement.cells[1].children;
    for(var i=0;i<_array.length;i++)
    {
     alert(_array[i].value);
     }
    
   }

 <table id="table1" border=1 width=300 cellpadding=1 cellspacing=1>
<td>10</td>
  <td><input type="text" id="txt1" value="123">
    <input type="text" id="txt2" value="456">
    <input type="text" id="txt3" value="789">11
  </td>
  <td><input type=button value="测试" onclick="test(this);" /></td>
  </tr>
</table>
posted @ 2007-03-07 16:35  RobotTech  阅读(907)  评论(0编辑  收藏  举报