How to find anchor tags in a page using javascript

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


OUTPUT appears as
Number of anchor tags are :2

Comments or Responses

Login to post response