I think you are missing the point of Element.next() and Element.down().

Assuming you run the code you pasted into another message in this thread:

$$('.cancel').each( function(element) {
alert($(element).next()); // returns undefined ????? ....
alert($(element).down()); // returns undefined ????? ....

This gets element with class .cancel, in the DOM below it is an 
<img...> element, LAST element inside the <div class="button-holder">.

As it is the last element inside that div, then it has no siblings 
after it, so there is no next() element. If you try to run 
Element.prev() on this element, it should return the previous img, 
with class "save".

Same with Element.down(); IMG elements can have NO children. There are 
no children elements of your img.cancel tag, then down() returns null.
If you try to go up() the DOM, then you will reach the parent element 
of your img - <div class="button-holder">.

What I am trying to say is that you can go next() and prev() only on 
same DOM branch, you can not "jump" to another branch.

To reach <div id="salary2-wrapper"> from <img class="cancel"> you need 
to go up() from IMG, and then go next().


Jeztah wrote:
> <div class="button-holder">
>   <img class="save" alt="Save The Changes" src="/resources/includes/
> images/smallsave.png"/>
>   <img class="cancel" alt="Cancel Changes" src="/resources/includes/
> images/smallcancel.png"/>
> </div>
> <div id="salary2-wrapper" class="tf edit editYes" title="Click to
> edit!" style="margin: 0pt; padding: 0pt;">
> <input id="employment_details-fa5a746-1-salary2-integer" class="1 2 tf
> editBox" type="text" value="20,000"/>
> </div>
> with the above DOM / Html setup i have invoked a click on
> class="cancel" like so ..
> how can this possibly be if the html is nowhere near the end of the
> document ? .. its confusing the hell out of me, or am i missing the
> point of what next() / down() are meant to do .. as i was under the
> impression that they were to traverse up and down the DOM !!
> > 

You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to