<TABLE id="x"> <THEAD> <TR> <TD> This text is in the THEAD. </TD> </TR> </THEAD> <TBODY> <TR> <TD> This text is in the TBODY. </TD> </TR> </TBODY> </TABLE> <input type=button onclick="document.getElementById('x').getElementsByTagName('tbody')[0].parentNode.removeChild(document.getElementById('x').getElementsByTagName('tbody')[0])">获得某行的所有td row = document.getElementById('x').rows[0] for(i = 0;i<row.cells.length;i++) { alert(row.cells[i].innerHTML) }
<THEAD>
<TR>
<TD>
This text is in the THEAD.
</TD>
</TR>
</THEAD>
<TBODY>
<TR>
<TD>
This text is in the TBODY.
</TD>
</TR>
</TBODY>
</TABLE>
<input type=button onclick="document.getElementById('x').getElementsByTagName('tbody')[0].parentNode.removeChild(document.getElementById('x').getElementsByTagName('tbody')[0])">获得某行的所有td
row = document.getElementById('x').rows[0]
for(i = 0;i<row.cells.length;i++)
{
alert(row.cells[i].innerHTML)
}
row = document.getElementById('x').rows[m]