日期:2014-05-16 浏览次数:20474 次
<!DOCTYPE HTML> <html> <head> <meta charset="gb2312" /> <title></title> <style> </style> </head> <body> <table id="myTable" border="1"> <thead> <tr> <th>Month</th> <th>Savings</th> <th>Savings33</th> </tr> </thead> <tbody> <tr> <td>January</td> <td>$100</td> </tr> <tr> <td>February</td> <td>$80</td> </tr> </tbody> <tbody> <tr> <td>January</td> <td>$102</td> </tr> <tr> <td>February</td> <td>$82</td> </tr> </tbody> <tbody> <tr> <td>January</td> <td>$300</td> </tr> <tr> <td>February</td> <td>$380</td> </tr> </tbody> </table> <script src="https://ajax.googleapis.com/ajax/libs/mootools/1.3.2/mootools-yui-compressed.js"></script> <script> alert( $('myTable').getChildren('tbody').length ) </script> </body> </html>
------解决方案--------------------
<script type="text/javascript">
myTable=document.getElementById("myTable");
tbody = myTable.getElementsByTagName("tbody");
alert(tbody.length);
</script>