How do I write jQuery selector to test if li has ul that has at least one li that is not .disabled (may be other classes or without class at all).
Yes sounds complex but it’s simple – I need to know if there’re uls that do not have “disabled” class on inner lis.
Something like
$("li").filter("*:has(ul:has(li:not(.disabled)))")
You can shorten it a bit, like this:
You can try it here. Since the
<li>is a child of<ul>you can just refer to it that way, no need for the extra:has()selector confusing Sizzle (multiple:not()in a chain do this as well).Unless there’s the possibility of a
<ol>you could remote theulpart as well, just having: