class method Element.previousSiblings
Element.previousSiblings(element) → [Element…]
Collects all of element
's previous siblings and returns them as an
Array
of elements.
Two elements are siblings if they have the same parent. So for example,
the <head>
and <body>
elements are siblings (their parent is the
<html>
element). Previous-siblings are simply the ones which precede
element
in the document.
The returned Array
reflects the siblings inversed order in the
document (e.g. an index of 0 refers to the lowest sibling i.e., the one
closest to element
).
Note that all of Prototype's DOM traversal methods ignore text nodes and return element nodes only.
Examples
<ul> <li id="golden-delicious">Golden Delicious</li> <li id="mutsu">Mutsu</li> <li id="mcintosh">McIntosh</li> <li id="ida-red">Ida Red</li> </ul>
Then:
$('mcintosh').previousSiblings(); // -> [li#mutsu, li#golden-delicious] $('golden-delicious').previousSiblings(); // -> []
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.