Categories
jquery list php

jQuery odd even on nested list

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?

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");