Home > Article > Web Front-end > JavaScript method to return the number of anchors in a web page_javascript skills
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.