jQuery nth-Child Method - :nth-child() Tutorial

Read the tutorial on YogiHosting »

1. Change the background color of 2nd element - :nth-child(2)

First

Second

Third

Fourth

2. Change the background color for even (:nth-child(even)) and odd (:nth-child(odd)) elements

First

Second

Third

Fourth

3. Change the background color for elements using formula (:nth-child(2n+3))

First

Second

Third

Fourth

Fifth

Sixth

Seventh

Eight