<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> </td><td>nbsp;</td>
</tr>
<tr>
<td> </td><td>nbsp;</td>
</tr>
</table>
<input type="button" οnclick="show();"/>
</body>
</html>
JavaScript中取得表格的行数和列数(适合IE)
最新推荐文章于 2024-09-10 06:15:30 发布