Software Developer

jQuery nth-child Selectors For 3-Column Gallery

This is a quick reference cheat sheet for jQuery :nth-child selectors.

I say this is for a ‘3-column gallery’ because that is what I use this most for.

To select every 1st-column element, which would be the 1st, 4th child, 7th child, 10th child, etc., use:

:nth-child(3n+1)

To select every middle-column element, which would be the 2nd child, 5th child, 8th child, 11th child, etc., use:

:nth-child(3n+2)

To select every 3rd-column element, which would be the 3rd child, 6th child, 7th child, 12th child, etc., use:

:nth-child(3n+3)

By

Questions and Comments are Welcome

Your email address will not be published. All comments will be moderated.

Please wrap code in "code" bracket tags like this:

[code]

YOUR CODE HERE 

[/code]