The DOM anchors collection is used to return the collection of all <a> element in a HTML document. It only count those <a> element that have the name attribute only. The name attribute of anchor element does not supported in HTML 5. The elements in the collection are sorted that appear in the sourcecode.
Property: The anchor collection property contains a value length which returns the number of <a> elements in the document.
Methods: The DOM anchors collection contains three methods which are given below:
- [index]: It is used to return the <a> element of selected index. The index value starts with 0. It returns NULL if the index value is out of range.
- item(index): It is used to return the <a> element of selected index. The index value starts with 0. It returns NULL if the index value is out of range.
- namedItem(id): It is used to return the <a> element from the collection with given id attribute. It returns NULL if the id is not valid.
Supported Browsers: The browser supported by DOM anchors collection are listed below:
- Apple Safari
- Google Chrome
- Internet Explorer
- How to remove underline for anchors tag using CSS?
- HTML | DOM embeds Collection
- HTML | DOM scripts Collection
- HTML | DOM forms Collection
- HTML | DOM applets Collection
- HTML | DOM links Collection
- HTML | DOM Table rows Collection
- HTML | DOM Table tBodies Collection
- HTML | DOM images Collection Property
- HTML | DOM Datalist options Collection
- PHP | Ds\Collection toArray() Function
- PHP | Ds\Collection isEmpty() Function
- PHP | Ds\Collection copy() Function
- PHP | Ds\Collection clear() Function
- CSS | Generic font-family collection
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.