Monday, January 13, 2014

getElementByTagName() method example :-

The getElementByTagName() method returns all the element.


<html>
<body>
<script type="text/javascript">
function mahi()
{
var prgf=document.getElementsByTagName("p");
alert("total p tags are: "+prgf.length);
}
</script>

<p>This is a pragraph</p>
<p>Here we are going to count total number of paragraphs by getElementByTagName() method.</p>
<p>Here is the simple example.</p>
<p>I am Mahi Babariya.</p>
<p>I Love My parents alot</p>

<button onclick="mahi()">Count Paragraph</button>
</body>
</html>

No comments:

Post a Comment