Prototype - DOM Traversal with up()
- by Jason McCreary
I have the following structure:
<form>
<div class="content">
...
</div>
<div class="action">
<p>Select <a class="select_all" href="?select=1" title="Select All">All</a></p>
</div>
</form>
I am using Prototype's up() to traverse the DOM in order to find the <form> element in respect to the a.select_all. However the following doesn't work:
select_link.up('form'); // returns undefined
Yet, this does.
select_link.up().up().up(); // returns HTMLFormElement
Clearly this is an ancestor of a.select_all. The API Docs state Element.up() supports a CSSRule. What am I missing here?