JavaScript links Property Tutorial

In this section, we will learn what the document links property is and how to use it in JavaScript.

What is document links Property in JavaScript?

The JavaScript document links property is used to return an object that contains the entire <a> and <area> elements on a page.

Note: the returned-collection of this property only contains the <a> and <area> elements on a page that assigned a value for the `href` attribute.

This means if there’s an <a> element in a page but without the `href` attribute, then it won’t be added as the items in the returned a collection of this property.

document links Property Syntax:

document.links;

document links Property Input Value

The property is read-only.

document links Property Return Value

The return value of this property is a reference to a collection that contains the <a> and <area> elements on a page that has the `href` attribute with a value assigned to it.

Example: using document links Property in JavaScript

See the Pen using document links Property in JavaScript by Omid Dehghan (@odchan1) on CodePen.

Facebook
Twitter
Pinterest
LinkedIn

Top Technologies