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>

版权声明:本文为RobotTech原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/RobotTech/archive/2007/03/07/666983.html