Описание тега nodelist

The NodeList interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented. NodeList objects in the DOM are live. The items in the NodeList are accessible via an integral index, starting from 0.

Summary

NodeList objects are collections of nodes returned by getElementsByTagName, getElementsByTagNameNS, Node.childNodes, querySelectorAll, getElementsByClassName, etc.

Properties

length

Reflects the number of elements in the NodeList.

Methods

item ( idx )

Returns an item in the list by its index, or null if out-of-bounds. Equivalent to nodeList[idx]

Description

A "live" collection

In most cases, the NodeList is a live collection. This means that changes on the DOM tree are going to be reflected on the collection.

var links = document.getElementsByTagName('a');
// links.length === 2 for instance.
document.body.appendChild( links[0].cloneNode(true) ); // another link is added to the document
// the 'links' NodeList is automatically updated
// links.length === 3 now.

If the NodeList is the return value of document.querySelectorAll, it is NOT live.