如果你想遍历每一行(),知道/识别row(),并循环访问每行()的每个列(),那么这就是要走的路。<tr>
<tr>
<td>
<tr>
var table = document.getElementById("mytab1");
for (var i = 0, row; row = table.rows[i]; i++) {
//iterate through rows
//rows would be accessed using the "row" variable assigned in the for loop
for (var j = 0, col; col = row.cells[j]; j++) {
//iterate through columns
//columns would be accessed using the "col" variable assigned in the for loop
}
}
如果你只是想遍历cell(),忽略你所在的行,那么这就是要走的路。<td>
var table = document.getElementById("mytab1");
for (var i = 0, cell; cell = table.cells[i]; i++) {
//iterate through cells
//cells would be accessed using the "cell" variable assigned in the for loop
}