jQuery:
$("li:even div").removeClass("odd even").addClass("odd");
$("li:odd div").removeClass("odd even").addClass("even");
http://jsfiddle.net/hashie5/vk6rZ/
As you can see in the fiddle, odd/even does not work properly, what am I doing wrong?
Here is a working example
http://jsfiddle.net/joycse06/vk6rZ/4/
target immediate children (divs)
$("li:even > div").removeClass("odd even").addClass("odd");
$("li:odd > div").removeClass("odd even").addClass("even");
look at the li:even>div
instead of li:even div
$("li:even>div").removeClass("odd even").addClass("odd");
$("li:odd>div").removeClass("odd even").addClass("even");
You can use this: http://jsfiddle.net/hashie5/vk6rZ/
$("li:even > div").removeClass("odd even").addClass("odd");
$("li:odd > div").removeClass("odd even").addClass("even");
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