Home  >  Article  >  Web Front-end  >  JavaScript method to return the number of anchors in a web page_javascript skills

JavaScript method to return the number of anchors in a web page_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:05:401011browse

The example in this article describes how JavaScript returns the number of anchor points in a web page. Share it with everyone for your reference. The details are as follows:

JavaScript returns the number of anchors in the web page. The following JS code gets the number of anchors in the page

<!DOCTYPE html>
<html>
<body>
<a name="html">HTML Tutorial</a><br>
<a name="css">CSS Tutorial</a><br>
<a name="xml">XML Tutorial</a><br>
<a href="http://www.jb51.net/">JavaScript代码</a>
<p>Number of anchors:
<script>
document.write(document.anchors.length);
</script></p>
</body>
</html>

I hope this article will be helpful to everyone’s JavaScript programming design.

Statement:
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