tags:

views:

7

answers:

1

Hi, having read through how to use nextall() i'm still a little stumped with the following: I have a loop that will be outputting the following code.

<div id="placement" style="float:right"> 
    <a class="eng-sum"><img src="/flags/en.png"></a>
</div>

<div class="tool-summary" id="tool-summary" style="clear:both; display:none">
    blar blar
</div>

I looking to click on uk flag and display the next div.tool-summary

Here is the jquery script I'm using:

$('.eng-sum').click(function() {   

   $(this).nextAll(".tool-summary:first").slideToggle();

});

This script only works if I wrap the .tool-summary div within the #placement div which is undesirable - I thought that the nextall() function would take care of this, but it seems not to?

A: 

nextAll finds siblings only. That is to say, it only looks at elements within the same parent element.

You might want to look at using

$(this).parent().nextAll(".tool-summary:first").slideToggle();

This searches among siblings of the #placement div.

lonesomeday
Thanks for this, it works well. How would i go about getting a hold on a div within the .tool-summary? I have tried this: $(this).parent().nextAll(".tool-summary:first").next(".eng").show();
squeaker
`$(this).parent().nextAll('.tool-summary:first').find('.eng').show()k`
lonesomeday
Great, thanks a lot for you help.
squeaker