Prototype - DOM Traversal with up()
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'开发者_如何学Got 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?
It works fine by me: http://jsfiddle.net/f9HdB/
You can simply use Function#bind instead of Function#bindAsEventListener.
Do you used a code like this:
var select_link = $$('.select_all').first()
to get the DOM-Object of the link?
精彩评论