This should do it:

$("div:even").addClass("superCoolClass");

On 4/6/07, Jeffrey Kretz <[EMAIL PROTECTED]> wrote:


I'm not 100% sure I follow your question, but you could do this:

$('div').each(function(i)
        {
                if (i%2)
                {
                        $(this).addClass('newClass');
                }
        });

"i" is a variable passed by the each method that starts at 0 and
increments
by one for each element it is handling.

JK

-----Original Message-----
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Tom Shafer
Sent: Friday, April 06, 2007 7:11 PM
To: jQuery (English)
Subject: [jQuery] Traversing the dom selecting ever other dom


I was wondering how I can traverse through the dom and start at a div
and then select every other div until i want it to stop so that I may
add a class to it.

Any Ideas?

Thanks

Tom





--
Aaron Heimlich
Web Developer
[EMAIL PROTECTED]
http://aheimlich.freepgs.com

Reply via email to