recursivelyCollect :: Element

recursivelyCollect(element, property) -> [HTMLElement...] Recursively collects elements whose relationship is specified by property. property has to be a property (a method won’t do!) of element that points to a single DOM node. Returns an array of extended elements.

This method is used internally by ancestors(), descendants(), nextSiblings(), previousSiblings() and siblings() which offer really convenient way to grab elements, so directly accessing recursivelyCollect() should seldom be needed. However, if you are after something out of the ordinary, it is the way to go.

Note that all of Prototype’s DOM traversal methods ignore text nodes and return element nodes only.

Examples

<ul id="fruits">

<li id="apples">

<ul id="list-of-apples">

<li id="golden-delicious"><p>Golden Delicious</p></li>

<li id="mutsu">Mutsu</li>

<li id="mcintosh">McIntosh</li>

<li id="ida-red">Ida Red</li>

</ul>

</li>

</ul>

$('fruits').recursivelyCollect('firstChild');

// -> [li#apples, ul#list-of-apples, li#golden-delicious, p]

See also

Element: ancestors | descendants | nextSiblings | previousSiblings | siblings

Prototype API 1.5.0 - prototypejs.org