recursivelyCollect
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 Element.ancestors
, Element.descendants
, Element.nextSiblings
, Element.previousSiblings
and Element.siblings
which offer really convenient way to grab elements, so directly accessing Element.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]