JavaScript DOM own property: anchors
[this page | pdf | back links]
The anchors property
of the JavaScript
DOM returns a
collection of all <a>
elements that have a name
attribute.
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
<a id="x1" href="http://www.nematrian.com/Introduction.aspx">Website Introduction</a><br>
<a id="x2" href="http://www.nematrian.com/HTMLCSSJSTutorial.aspx">HTML/CSS/JavaScript Tutorial</a><br>
<a id="x3">Link without an href attribute set</a><br><br>
<span id="x0"></span>
<script>
var n0 = document.getElementById("x0");
n0.innerHTML = "Number of anchor elements = " + document.anchors.length + "<br>"
+ "Number of links with href set = " + document.links.length + "<br>"
</script>
</body>
</html>
|
NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)