I have below markup,
<ul>
<li>1</li> //light BG
<li>2</li>
<li>3</li>
<li>4</li> //light BG
<li>5</li>
<li>6</li>
......
</ul>
I want to add class dark and light, as per position of li.
li should be lightdarklight$('ul li:nth-child(3n-2)').addClass('light');
$('ul li::not(:nth-child(3n-2))').addClass('dark');
DEMO
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With