From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/api/htmlcollection/item/index.html | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 files/zh-cn/web/api/htmlcollection/item/index.html (limited to 'files/zh-cn/web/api/htmlcollection/item') 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 +--- +

{{APIRef("HTML DOM")}}

+ +

HTMLCollection.item() 由位置获取元素.

+ +

参数

+ +
+
index
+
想要被返回的Node的位置. 元素在HTML Collection中的顺序和他们在源文档的顺序保持一致。
+
+ +

返回值

+ +

指定的index的{{domxref("Node")}} , 如果index小于0或者不小于它的长度属性则返回null。

+ +

Description

+ +

HTMLCollection中item( )方法返回一个编号的元素 ,在JavaScript中把HTMLCollection当成是一个是数组并用数组符号去索引十分简单。

+ +

Example

+ +
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
+
+ +

See also

+ + -- cgit v1.2.3-54-g00ecf