HTML DOM Document anchors
Examples
The number of <a> elements in a document:
let num = document.anchors.length;
Try it Yourself »
The content of the first <a> element:
let content = document.anchors[0].innerHTML;
Try it Yourself »
Description
The anchors property is deprecated. Do NOT use it.
The anchors property only returns those <a> elements with a name attribute.
The name attribute of the <a> element is not supported in HTML5.
Alternatives
The number of <a> elements in a document:
let num = document.getElementsByTagName("a").length;
Try it Yourself »
The content of the first <a> element:
let content = document.getElementsByTagName("a")[0].innerHTML;
Try it Yourself »
Syntax
document.anchors
Parameters
NONE |
Return Value
Type | Description |
Object | An HTMLCollection of all lt;a> elements in the document that have a name attribute. |
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.