I have a random amount of DIVs (minimum 1, max of 10)
<div id="container">
<div class="foo">Content</div> <!-- div 1 -->
<div class="foo">Content</div> <!-- div 2 -->
<div class="foo">Content</div> <!-- div 3 -->
<div class="foo">Content</div> <!-- div 4 -->
<div class="foo">Content</div> <!-- div 5 -->
<div class="foo">Content</div> <!-- i need this one hidden -->
<div class="foo">Content</div> <!-- and this one -->
</div>
I want the first 5 divs to be visible (either with .show() or with a class, doesn't matter). Any additional DIVs should be hidden.
I then simulate the "closing" of a div with:
$('.foo').click(function(){
$(this).fadeOut('slow');
});
which removes the clicked div, causing all the divs below to move up one. This is my desired effect.
however, I need some logic here.
If I have less than 5 DIVS, the close facility should be disabled. If I have more than 5 DIVs, then when a div is "closed", i want the next "hidden" div to become visible.
I can add IDs to each DIV if required with IDs like "foo1" "foo2" etc.
hope this is clear enough
thanks