codice HTML:
<script type="text/javascript">      
function countpara(){      
var totalpara = document.getElementsByName("primo").length;      
alert("total tag che si chiamano 'primo': "+totalpara); 
var totalpara = document.getElementsByTagName("td").length;    
alert("total td tags are: "+totalpara);            
}      
</script>    
<table>    
 <tr>
    <td name="primo" value="abcdefg">This is a pragraph</td>      
 <td>Here we are going to count total number of paragraphs by getElementByTagName() method.</td>      
 <td>Let's see the simple example</td>      
 </tr> 
</table>    
<button onclick="countpara()">count paragraph</button>