Thanks for the help Klaus. Karl you're code actually worked out
better. I need to count 1, 2, 3...1, 2, 3...adding a class each time.

Sweet! Thanks for the help. I'm really digging the book too. Nice
work!

Take care,

Adam

On Oct 1, 7:39 pm, Karl Swedberg <[EMAIL PROTECTED]> wrote:
> Hey Adam,
>
> Glad you found that! :-)  Klaus's version is a lot simpler, though,
> so you might want to try that instead. At press time, the :nth-child
> () didn't allow for something like  :nth-child(3n) or  :nth-child(3n
> +2); it just took a single number, like :nth-child(3). It's much more
> robust now.
>
> Cheers,
>
> --Karl
> _________________
> Karl Swedbergwww.englishrules.comwww.learningjquery.com
>
> On Oct 1, 2007, at 6:24 PM, Adam Stacoviak wrote:
>
> > I figured it out...I just needed to do a bit more reading to my
> > Learning jQuery book!
>
> > var classNames = {
> >     0: 'first',
> >     1: 'second',
> >     2: 'third'
> > };
>
> > $('#section_wrapper_div .section_item').each(function(index) {
> >     $(this).addClass(classNames[index % 3]);
> > });
>
> > On 10/1/07, Adam Stacoviak <[EMAIL PROTECTED]> wrote:
> > I'm trying to find out how to add a class to every third occurrence of
> > an element.
>
> > Basically, I have a DIV with an undefined number of DIVs inside of it,
> > and I want to add a class to every third DIV.
>
> > Thanks!

Reply via email to