I've tried searching for an answer, but without joy - I'm new to JS (as in started learning last week), and I've hit a problem that I don't even know where to look to start solving.
I have a div with the id container, inside that div are lots of little divs with the class item. I want to give those .items the additional classes of tile1 for the first div, tile2 for the second, tile3 for the third, tile4 for the fourth, then going back to tile1 for the fifth, tile2 for the sixth etc.
The amount of .tiles in the #container will be dynamically generated, possibly with waypoints using infinite scroll, which makes me want to use javascript to do this rather than manually type these classes in.
Can anyone give me some pointers?
Thanks!
:nth-child(4n+1)will get the first, fifth, ninth... You can also do4n+2,4n+3and4n.