日期:2014-05-16  浏览次数:20326 次

javaScript处理TAble
请问在JavaScript里怎么样得到Table的行数和列数

------解决方案--------------------
document.all.mytable.rows.length //行数
document.all.mytable.rows(i).cells.length //第i行的列数
------解决方案--------------------
:D
曾分。。
<table id= "wc " width= "150 " border= "1 ">
<tr>
<td> 1 </td>
<td> 2 </td>
<td> 3 </td>
</tr>
</table>
<script type= "text/javascript ">
window.onload = function () {
var wc = document.getElementById( "wc ").getElementsByTagName( "tbody ")[0];
alert( "行数: " + wc.rows.length + "\n " + "第一行列数: " + wc.rows[0].cells.length);
};
</script>
------解决方案--------------------
document.all.mytable.rows.length //行数 
document.all.mytable.rows(i).cells.length //第i行的列数
正解!
------解决方案--------------------
document.all.mytable.rows.length //行数
document.all.mytable.rows(i).cells.length //第i行的列数


完全正确