跳转到:

links 属性返回一个文档中所有具有 href 属性值的 <area> 元素与 <a> 元素的集合。

语法

nodeList = document.links 

返回值

一个 HTMLCollection

示例

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);
}

规范

规范 状态 备注
HTML Living Standard
Document.links
Living Standard
Document Object Model (DOM) Level 2 HTML Specification
document.links
Obsolete Initial definition

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
linksChrome Full support 1Edge Full support 12Firefox Full support YesIE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown

文档标签和贡献者

标签: 
此页面的贡献者: RainSlide, teoli, AlexChao
最后编辑者: RainSlide,