<script type="text/javascript">
function getVal()
{
var tab = document.getElementById("tab");
var rows = tab.rows.length;
for(var i = 1; i < rows; i++)
{
var cols = tab.rows[i].childNodes;
for(var m = 0; m < cols.length; m++)
{
alert(cols[m].innerText);
}
}
}
</script>
<table id="tab">
<tr>
<th>学号</th>
<th>姓名</th>
</tr>
<tr>
<td>001</td>
<td>隆美尔</td>
</tr>
<tr>
<td>002</td>
<td>希特勒</td>
</tr>
</table>
<input type="button" value="获取table值" onclick="getVal()"/>
追问谢谢...我是想要td中input 控件的值
追答
function getVal()
{
var tab = document.getElementById("tab");
var rows = tab.rows.length;
for(var i = 1; i
学号
姓名