Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript jQuery :nth-child Re: jQuery :nth-child

#73400
andiszek
Participant

hello,
very nice trick! i`ve played around and it does magic:) thanks.

i have a quick question: is there any possibility to add multiple styles to the selected children?
for now this works, but i`d like to add 2 or morestyles at once:

$(".wrappingDiv div:nth-child(3n+3)").css("margin-right", 0);
$(".wrappingDiv div:nth-child(3n+3)").css("background", "#333");
is there any way to combine them?

or even simpler:
is it possible to add to each nth child a special class, (eg: ".3rd" ), so i can control it via the external CSS file only?

thanks,
andi