when u do '.gallery li', that selector returns an array with every li that matches. the :gt(2) refines it to every li within that result set greater than 2.
what u need is to keep each .gallery ul separate. try this: $('.gallery').each( function(){ $(this).children('li').hide(); } ); u haven't tested the code, so it prob won't work, but u get the idea. -phong On Jan 16, 2:16 am, 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