I see a few problems:
div:nth-child(2) will only select the 2nd child NOT every odd child.
Try the following:
$("#search-results div:nth-child(odd):gt(1)").addClass("stripes");
that should select all your odd child divs except the first two and give
them the class "stripes"
Dan Eastwell wrote:
>
> Hello,
>
> I'm trying to select every odd item in a list, but not the first two
> items.
>
> I've tried using the nth-child selector, which is fine at picking out
> the nth-child, but I can't get the 2n+2 child to be selected:
>
> stripes("#search-results div:odd"); // is ok
> stripes("#search-results div:nth-child(2)"); // works
>
> but
>
> stripes("#search-results div:nth-child(2n+2)"); // doesn't.
>
> Am I missing something about the CSS3 selector syntax?
>
> Thanks,
>
> Dan.
>
> --
> Daniel Eastwell
>
> Portfolio and articles:
> http://www.thoughtballoon.co.uk
>
> Blog:
> http://www.thoughtballoon.co.uk/blog
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
>
--
View this message in context:
http://www.nabble.com/nth-child-selector-tf3308588.html#a9212414
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/