Adding classes to LI with JQuery LI to every 7th item
javascript, jquery
Solution
Try:
$('ul li:nth-child(7n+1)').addClass("first");
This will select every 7th element.
See demo on jsFiddle.
Problem
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.