aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/htmlcollection/item
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/htmlcollection/item
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/htmlcollection/item')
-rw-r--r--files/zh-cn/web/api/htmlcollection/item/index.html36
1 files changed, 36 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/htmlcollection/item/index.html b/files/zh-cn/web/api/htmlcollection/item/index.html
new file mode 100644
index 0000000000..4d1ad8a5c8
--- /dev/null
+++ b/files/zh-cn/web/api/htmlcollection/item/index.html
@@ -0,0 +1,36 @@
+---
+title: HTMLCollection.item
+slug: Web/API/HTMLCollection/item
+translation_of: Web/API/HTMLCollection/item
+---
+<p>{{APIRef("HTML DOM")}}</p>
+
+<p><code>HTMLCollection.item()</code> 由位置获取元素.</p>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt>index</dt>
+ <dd>想要被返回的Node的位置. 元素在HTML Collection中的顺序和他们在源文档的顺序保持一致。</dd>
+</dl>
+
+<h3 id="返回值">返回值</h3>
+
+<p>指定的index的{{domxref("Node")}} , 如果index小于0或者不小于它的长度属性则返回null。</p>
+
+<h2 id="Description">Description</h2>
+
+<p>HTMLCollection中item( )方法返回一个编号的元素 ,在JavaScript中把HTMLCollection当成是一个是数组并用数组符号去索引十分简单。</p>
+
+<h2 id="Example">Example</h2>
+
+<pre class="brush: js">var c = document.images; // This is an HTMLCollection
+var img0 = c.item(0); // You can use the item( ) method this way
+var img1 = c[1]; // But this notation is easier and more common
+</pre>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li>{{domxref("NodeList.item()")}}</li>
+</ul>