--- title: HTMLCollection.item slug: Web/API/HTMLCollection/item translation_of: Web/API/HTMLCollection/item ---
{{APIRef("HTML DOM")}}
HTMLCollection.item()
由位置获取元素.
指定的index的{{domxref("Node")}} , 如果index小于0或者不小于它的长度属性则返回null。
HTMLCollection中item( )方法返回一个编号的元素 ,在JavaScript中把HTMLCollection当成是一个是数组并用数组符号去索引十分简单。
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