jquery displaying an unnested div using nextall
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?
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.
精彩评论