当前位置: 代码迷 >> JavaScript >> 怎样对 TR 中的 TD 中的 INPUT 取值、赋值?该怎么处理
  详细解决方案

怎样对 TR 中的 TD 中的 INPUT 取值、赋值?该怎么处理

热度:136   发布时间:2012-02-15 12:09:44.0
怎样对 TR 中的 TD 中的 INPUT 取值、赋值?
怎样对 TR 中的 TD 中的 INPUT 取值、赋值?

怎么对下表中的  input 取值、赋值?


<table>
<tr id="guest_1">
<td><input type="text" name="name" id="name" value="1111"></td>
<td><input type="text" name="weight" id="weight"></td>
</tr>
<tr id="guest_2">
<td><input type="text" name="name" id="name" value="2222"></td>
<td><input type="text" name="weight" id="weight"></td>
</tr>
<tr id="guest_3">
<td><input type="text" name="name" id="name" value="3333"></td>
<td><input type="text" name="weight" id="weight"></td>
</tr>
</table>


------解决方案--------------------
JScript code
var tr = document.getElementById("guest_1");
var name = tr.childNodes[0].firstChild.value;
var weight = tr.childNodes[1].firstChild.value; 
  相关解决方案