HTML DOM Document anchors property
- Previous Page adoptNode()
- Next Page Applets
- Go to the Previous Level HTML DOM Documents
Definition and Usage
Not recommended anchors
property. Please do not use it.
anchors
The property only returns those <a> elements with the name attribute.
HTML5 does not support the name attribute of <a> elements.
Alternative:
Number of <a> elements in the document:
let num = document.getElementsByTagName("a").length;
Content of the first <a> element:
let content = document.getElementsByTagName("a")[0].innerHTML;
See also:
Instance
Example 1
Number of <a> elements in the document:
let num = document.anchors.length;
Example 2
Content of the first <a> element:
let content = document.anchors[0].innerHTML;
Syntax
document.anchors
Parameter
None.
Return Value
Type | Description |
---|---|
Object | An HTMLCollection of all <a> elements in the document that have a name attribute. |
- Previous Page adoptNode()
- Next Page Applets
- Go to the Previous Level HTML DOM Documents