JS 取table 值得问题
<table>
<tr>
<td><input type="text" value="122"/></td>
<td><input type="text" value="22"/></td>
<td><input type="text" value="221"/></td>
<td><input type="text" value="44"/></td>
</tr>
<tr>
<td><input type="text" value="77"/></td>
<td><input type="text" value="25452"/></td>
<td><input type="text" value="25421"/></td>
<td><input type="text" value="54"/></td>
</tr>
<tr>
<td><input type="text" value="14522"/></td>
<td><input type="text" value="2542"/></td>
<td><input type="text" value="25421"/></td>
<td><input type="text" value="54"/></td>
</tr>
</table>
现在的问题是怎么让让标红的这三列的值相加,现在取不到值 知道该怎么取, document.getElementById("Table1").rows[1][11].innerHTML;这么应该能得到 不带控件的值 但是带有 text 控件了不知道怎么取。
[解决办法]
- HTML code
<html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title> <SCRIPT src="http://gt123.cn/js/j142.js" type=text/javascript></SCRIPT> <script> function aa() { var total = 0; $("tr>td:nth-child(3)>input").each(function () { total = total + $(this).val()*1; }); alert(total); } </script></head><body> <form id="form1" runat="server"><table><tr><td><input type="text" value="122"/></td><td><input type="text" value="22"/></td><td><input type="text" value="221"/></td><td><input type="text" value="44"/></td></tr><tr><td><input type="text" value="77"/></td><td><input type="text" value="25452"/></td><td><input type="text" value="25421"/></td><td><input type="text" value="54"/></td></tr><tr><td><input type="text" value="14522"/></td><td><input type="text" value="2542"/></td><td><input type="text" value="25421"/></td><td><input type="text" value="54"/></td></tr></table><input type="button" onclick="aa();" value="提交"/> </form></body></html>