How to find anchor tags in a page using javascript

Posted by Manideepgoud under JavaScript category on | Points: 40 | Views : 270
We can find how many anchor <a> tags are present in page using document.anchors.length using javascript DOM ELEMENTS.
<a name="dotnet">DotNetFunda</a><br />
<a name="online tutorial">TechFunda</a>
<p id="demo"></p>
document.getElementById('demo').innerHTML = "Number of anchor tags are:" + document.anchors.length;

OUTPUT appears as
Number of anchor tags are :2

Comments or Responses

Login to post response