How to alternate style (background color with jquery) for div inside div with id="container" alternately ( even and odd ) if I have HTML like this
<div id="container">
<div></div>
<div></div>
<div></div>
<div></div>
...
</div>
I know with table like
#tbl_users tr:nth-child(even) {background: #CCC;}
#tbl_users tr:nth-child(odd) {background: #FFF;}
but how to div apply something like this ?
Did you try:
div#container div:nth-child(even) {background: #CCC;}
div#container div:nth-child(odd) {background: #FFF;}
nth-child should work regardless of the tag.
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