Even better : $('a.filter').click(function() { $(this).closest('ul').children().removeClass('active').end().end().closest('li').addClass('active'); });
Michel Belleville 2009/11/29 Mauricio (Maujor) Samy Silva <css.mau...@gmail.com> > Try this: > > $('a.filter').click(function(){ > $(this).parent().siblings('li').removeClass('active'); > $(this).parent('li').addClass('active'); > }); > > MaurĂcio > > -----Mensagem Original----- > *De:* Charlie <charlie...@gmail.com> > *Para:* jquery-en@googlegroups.com > *Enviada em:* domingo, 29 de novembro de 2009 03:56 > *Assunto:* Re: [jQuery] Selector Help > ... > > Dave Maharaj :: WidePixels.com wrote: > How would I go about adding class to the li in this set up? > <li><a href="#" class="filter"><span>all</span></a></li> > <li><a href="#" class="filter"><span>some</span></a></li> > <li><a href="#" class="filter"><span>none</span></a></li> > > ... > > > >