instance method Element#childElements

View source on GitHub →

Element#childElements() → [Element…]

Collects all of the element's children and returns them as an array of Element.extended elements, in document order. The first entry in the array is the topmost child of element, the next is the child after that, etc.

Like all of Prototype's DOM traversal methods, Element.childElements ignores text nodes and returns element nodes only.

Example

Assuming:

<div id="australopithecus">
  Some text in a text node
  <div id="homo-erectus">
    <div id="homo-neanderthalensis"></div>
    <div id="homo-sapiens"></div>
  </div>
</div>

Then:

$('australopithecus').childElements();
// -> [div#homo-erectus]
 $('homo-erectus').childElements();
// -> [div#homo-neanderthalensis, div#homo-sapiens]
 $('homo-sapiens').childElements();
// -> []

Aliased as: Element#immediateDescendants

This method can be called either as an instance method or as a generic method. If calling as a generic, pass the instance in as the first argument.