addClass every nth

try

$("ul li:nth-child(3n+1)").addClass("A")
$("ul li:nth-child(3n+2)").addClass("B")
$("ul li:nth-child(3n)").addClass("C")

Feel free to consolidate it to make it prettier, but I wanted to expose the selectors.


I recommend something like this:

let i = 0;
$("li").each(function() {
    i++;
    let newClass = 'A';
    if (i % 3 == 1) { newClass = 'B'; }
    if (i % 3 == 2) { newClass = 'C'; }
    $(this).addClass(newClass);
});