var obj = $("ul"); obj.each(function(i) { var items = $("li", obj); items.each(function(i) { if(i < 3) { items.eq(i).show(); } else { items.eq(i).hide(); } }); });
On Sat, Jan 16, 2010 at 12:16 PM, alexander <alexan...@hulman.sk> wrote: > Hello everyone, > I've spent 2 hours with this already and I think I must be dumb or > blind since I can't find any hint online. > > I've got a couple of galleries as a <ul> in one page > <ul class="gallery" id="galleryid1"> > <li><img .....></li> > <li><img .....></li> > ... > ... > .. > </ul> > > <ul class="gallery" id="galleryid2"> > <li><img .....></li> > <li><img .....></li> > ... > ... > .. > </ul> > > etc.etc. > > For EACH of the <ul>s SEPARATELY I need to show only 3 <li>s and hide > the rest <li>. > > I tried > $(".gallery li:gt(2)").hide(); > The result is that only first 3 <li>s are shown and only in first > gallery. The rest is hidden. > I am looking for something like > $(".gallery:each li:gt(2)").hide(); > > What am I missing ? :) > > thanks for ideas. > Alexander >