HTMLCollection

Table of contents

  1. 1. Properties
  2. 2. Methods
  3. 3. Specification
  4. 4. See also
Table of contents
  1. 1. Properties
  2. 2. Methods
  3. 3. Specification
  4. 4. See also

HTMLCollection is an interface representing a collection of HTML elements (in document order) and offers methods and properties for traversing the list.

HTMLCollections in the HTML DOM are live; they will be automatically updated when the underlying document is changed.

The following lists each item (and its specific properties) which return an HTMLCollection: Document (images, applets, links, forms, anchors); form (elements); map (areas); table (rows, tBodies); tableSection (rows); row (cells)

Properties

  • length - A readonly attribute which returns an integer indicating the length of the list.

Methods

    item(index)
    returns the specific node at the given zero-based index (gives null if out of range). You can also specify the index in array-style brackets, without calling this method explicitly.
    namedItem(name)
    returns the specific node with the given DOMString (i.e., string) id or name (the latter only as a last resort, only in HTML, and only if the referenced element supports the name attribute). Returns null if no such named node exists. You can also specify the name in array-style brackets, without calling this method explicitly.

Tags (0)

Edit tags
  • No tags

Attachments (0)

 

Attach file