HTMLCollection.item()
由位置获取元素.
参数
- index
- 想要被返回的Node的位置. 元素在HTML Collection中的顺序和他们在源文档的顺序保持一致。
返回值
指定的index的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