In Javascript, this method is used to get the elements of specified tag name.
Parameter values :
Parameter : String -> This is required. And you give the tagname of that element you want to get .
Syntax:
document.getElementByTagName("name") ;
Example :
Javascript Code :
fun count()
var a = document.getElementByTagName("span") ;
alert("total span tags are :"+a.length);
}
Html Code :
<span>Hello </span>
<span>Mukesh </span>
<span>From Meerut </span>
<button onclick = "count()">count</button> // when you click on this, then function count( ) will call
Output :
total span tags are : 3
0 Comment(s)