I want to select list items that are immediate children of #nav, that do not themselves have immediate children with an 'active' class.
This is what I think it should be but it does not work:
$('#nav > li:not(> a.active)')
I want to select list items that are immediate children of #nav, that do not themselves have immediate children with an 'active' class.
This is what I think it should be but it does not work:
$('#nav > li:not(> a.active)')
This is how you do it:
I really like Ken's solution, but just for an alternative take.
You could add the active class to your list items instead of your links inside. Then your selector could look like:
If you want to style the links based on the active class, your CSS could look like this:
You'll need to use jQuery's
filter
function:For this jquery has the not selector
you can do something like