如何在表格中动态获取数据?由于我不知道该怎么做,我无法接受我的尝试。请不要考虑给出的例子:
<div id = "tbScore">
<table border="1" style="width:500px">
<tr>
<td>Jill</td>
<td>Smith</td>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</table>
答案 0 :(得分:0)
这就是你如何得到一个id为&#34; myTable&#34;的表的行数据:
var table = document.getElementById('myTable');
var rowLength = table.rows.length;
for (i = 0; i < rowLength; i++){
var cells = table.rows.item(i).cells;
var cellLength = cells.length;
for(var j = 0; j < cellLength; j++){
var cellVal = cells.item(j).innerHTML;
}
}