How to find how many links are present in a HTML page

Manideepgoud
Posted by Manideepgoud under JavaScript category on | Points: 40 | Views : 152
In order to find out how many links are present in the HTML page we use document.links.length.
 <a href="http://www.techfunda.com">TechFunda</a><br />
<a href="http://www.dotnetfunda.com">DotNetFunda</a>
<p id="demo"></p>
<script>
document.getElementById('demo').innerHTML = "Number of links in the page are :" + document.links.length;
</script>


We have given two links in the above code, document.links.length identifies how many links are present in a page.

OUTPUT
Number of links in the page are :2

Comments or Responses

Login to post response