document.links

  • Revision slug: Web/API/document.links
  • Revision title: document.links
  • Revision id: 406255
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment added lang: ITMoved From DOM/document.links to Web/API/document.links

Revision Content

{{ DomRef() }}

Summary

The links property returns a collection of all AREA elements and anchor elements in a document with a value for the href attribute.

Syntax

nodeList = document.links 

Example

var links = document.links;
for(var i = 0; i < links.length; i++) {
  var linkHref = document.createTextNode(links[i].href);
  var lineBreak = document.createElement("br");
  document.body.appendChild(linkHref);
  document.body.appendChild(lineBreak);
}

Specification

DOM Level 2 HTML: links

{{ languages( { "it": "it/DOM/document.links", "ja": "ja/DOM/document.links", "pl": "pl/DOM/document.links" } ) }}

Revision Source

<p>
{{ DomRef() }}
</p>
<h3 id="Summary" name="Summary">Summary</h3>
<p>The <code>links</code> property returns a collection of all AREA elements and anchor elements in a document with a value for the href attribute. </p>
<h3 id="Syntax" name="Syntax">Syntax </h3>
<pre class="eval"><i>nodeList</i> = document.links 
</pre>
<h3 id="Example" name="Example">Example </h3>
<pre class="eval">var links = document.links;
for(var i = 0; i &lt; links.length; i++) {
  var linkHref = document.createTextNode(links[i].href);
  var lineBreak = document.createElement("br");
  document.body.appendChild(linkHref);
  document.body.appendChild(lineBreak);
}
</pre>
<h3 id="Specification" name="Specification">Specification </h3>
<p><a class="external" href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-7068919">DOM Level 2 HTML: links</a>
</p>{{ languages( { "it": "it/DOM/document.links", "ja": "ja/DOM/document.links", "pl": "pl/DOM/document.links" } ) }}
Revert to this revision