$("div:nth-child(3n+1)").css("background", "#ff0000"); $("div:nth-child(3n)").css("background", "#cccccc");