diff options
Diffstat (limited to 'files/zh-cn/web/api/document/links/index.html')
-rw-r--r-- | files/zh-cn/web/api/document/links/index.html | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/document/links/index.html b/files/zh-cn/web/api/document/links/index.html new file mode 100644 index 0000000000..a5df44e0c6 --- /dev/null +++ b/files/zh-cn/web/api/document/links/index.html @@ -0,0 +1,60 @@ +--- +title: Document.links +slug: Web/API/Document/links +tags: + - API + - Document + - 属性 +translation_of: Web/API/Document/links +--- +<p>{{APIRef("DOM")}}</p> + +<p><code>links</code> 属性返回一个文档中所有具有 href 属性值的 {{HTMLElement("area")}} 元素与 {{HTMLElement("a")}} 元素的集合。</p> + +<h3 id="语法">语法</h3> + +<pre class="syntaxbox"><em>nodeList</em> = document.links </pre> + + +<h3 id="返回值">返回值</h3> + +<p>一个 {{domxref("HTMLCollection")}}。</p> + +<h3 id="示例">示例</h3> + +<pre class="brush: js">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); +} +</pre> + +<h3 id="规范">规范</h3> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">规范</th> + <th scope="col">状态</th> + <th scope="col">备注</th> + </tr> + <tr> + <td>{{SpecName('HTML WHATWG', '#dom-document-links', 'Document.links')}}</td> + <td>{{ Spec2('HTML WHATWG') }}</td> + <td> </td> + </tr> + <tr> + <td>{{SpecName("DOM2 HTML", "html.html#ID-7068919", "document.links")}}</td> + <td>{{Spec2("DOM2 HTML")}}</td> + <td>Initial definition</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + + + +<p>{{Compat("api.Document.links")}}</p> |