English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML DOM links attribute

HTML DOM Document Object

All browsers fully support the links property:the read-only attribute returns all<area>element and<A>a list of elements, where the href attribute has a value.

If the element is missinghrefIf the attribute is present, no content is returned.

The elements in the list are sorted in the order they appear in the source code.

语法:

Syntax:
var x = document.links.length;
Test and see‹/›

document.links

Browser Compatibility

Property
All browsers fully support the links property:linkslinkslinkslinkslinks

Is

PropertyDescription
lengthReturns the list of<a>and/or<area>Number of Elements

Method

MethodDescription
[index)Returns the specific node at the given index starting from zero in the list. If the index number is out of range, it returns null.
item(index)Returns the specific node at the given index starting from zero in the list. If the index number is out of range, it returns null.
namedItem(id)Returns a specific node whose ID name matches the string specified by name. If the id does not exist, it returns null.

Technical Details

Return Value:oneHTMLCollection, providing all <a> elements and/or list of <area> elements.
DOM Version:DOM Level1

More Examples

Find out how many links are in the document:

var x = document.links.length;
Test and see‹/›

HTML DOM Document Object