I am using this code to add a class to every 7th LI items and the first one too:
$('ul li:first, ul li:nth-child(7n)').addClass("first");
$('ul li:first, ul li:nth-child(1)').addClass("first");
My problem is that it just adds the class to the 1st and the 7th item but if I add another 7 or more it doesn't add it.
I need to add the class the every 7th li item.
Try:
$('ul li:nth-child(7n+1)').addClass("first");
This will select every 7th element.
See demo on jsFiddle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With