'tBodies' Example : tBodies « Javascript Collections « JavaScript DHTML






'tBodies' Example

    
<html>
<body>
<table id="myTable" width="16%" border="1">
    <tbody>
        <tr><td>Row 1</td></tr>
        <tr><td>Row 2</td></tr>
        <tr><td>Row 3</td></tr>
    </tbody>
    <tbody>
        <tr><td>Row 4</td></tr>
        <tr><td>Row 5</td></tr>
        <tr><td>Row 6</td></tr>
    </tbody>
</table>
<button onclick="function1;">Get total number of tbody elements</button>
<script language="JavaScript">
    function function1 {
        var m = document.getElementById("myTable").tBodies.length; 
        alert(m); 
    }
</script>
</body>
</html>

    
      
      








Related examples in the same category