Prototype - DOM Traversal with up()

Posted by Jason McCreary on Stack Overflow See other posts from Stack Overflow or by Jason McCreary
Published on 2010-05-26T16:08:57Z Indexed on 2010/05/26 16:11 UTC
Read the original article Hit count: 173

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about prototype