class method Element.ancestors
Element.ancestors(element) → [Element…]
Collects all of element
's ancestor elements and returns them as an
array of extended elements.
The returned array's first element is element
's direct ancestor (its
parentNode
), the second one is its grandparent, and so on until the
<html>
element is reached. <html>
will always be the last member of
the array. Calling ancestors
on the <html>
element will return an
empty array.
Example
Assuming:
<html>
[...]
<body>
<div id="father">
<div id="kid">
</div>
</div>
</body>
</html>
Then:
$('kid').ancestors();
// -> [div#father, body, html]
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.