就爱编程论坛

标题: JS获取表格行数和列数 [打印本页]

作者: admin    时间: 2011-7-8 12:54:28     标题: JS获取表格行数和列数

<html>
<head>
<script type="text/javascript">
    function show()
{
var tab = document.getElementById("test") ;
      //表格行数
      var rows = tab.rows.length ;
      //表格列数
      var cells = tab.rows.item(0).cells.length ;
alert("行数"+rows+"列数"+cells);
}
</script>
</head>
<body>
<table id="test" border="1">
<tr>
    <td>&nbsp;</td><td>nbsp;</td>
</tr>
<tr>
    <td>&nbsp;</td><td>nbsp;</td>
</tr>
</table>
<input type="button"/>
</body>
</html>





欢迎光临 就爱编程论坛 (http://bbs.waibc.com/) Powered by Discuz! X2