[jQuery] Re: 3,6,9,12...

2007-10-03 Thread Adam Stacoviak
, --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

[jQuery] 3,6,9,12...

2007-10-01 Thread Adam Stacoviak
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

[jQuery] Re: 3,6,9,12...

2007-10-01 Thread Adam Stacoviak
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