class method Element.childElements

View source on GitHub →

Element.childElements(element) → [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.



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


// -> [div#homo-erectus]
// -> [div#homo-neanderthalensis, div#homo-sapiens]
// -> []

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.