简单教程
提交运行
代码编辑器:
<script> function displayResult(){ alert(document.getElementById("myTable").tBodies.length); } </script> <table id="myTable" border="1"> <tbody> <tr> <td>cell 1</td> <td>cell 2</td> </tr> </tbody> <tbody> <tr> <td>cell 3</td> <td>cell 4</td> </tr> </tbody> </table> <br> <button type="button" onclick="displayResult()">显示表中 tbody 元素的数目</button>
运行结果: