Home > Web Front-end > JS Tutorial > body text

JavaScript method to get the number of hyperlinks in the page_javascript skills

WBOY
Release: 2016-05-16 15:33:19
Original
2482 people have browsed it

The example in this article describes the method of using JavaScript to obtain the number of hyperlinks in the page. Share it with everyone for your reference, the details are as follows:

Here is a demonstration of using JavaScript to obtain the number of hyperlinks on a page. Friends who are interested can learn from it.

The screenshot of the running effect is as follows:

The online demo address is as follows:

http://demo.jb51.net/js/2015/js-total-link-num-codes/

The specific code is as follows:

<html>
<head>
<title>JavaScript取得页面的超链接数</title>
<script language="javascript">
<!--
 function getLinks(){
  links = document.all.tags("A")
  total = links.length;
  alert("本页面共有" + total + "个超链接!");
 }
-->
</script>
</head>
<body onLoad="getLinks()">
<a href="#">a</a>
<a href="#">b</a>
<a href="#">c</a>
</body>
</html>
Copy after login

I hope this article will be helpful to everyone in JavaScript programming.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!