Reputation: 5309
how can I target all elements that have a sibling (and only those) in jQuery?
<ul>
<li>
<a href="#">target</a>
<ul>
<li><a href="#">no target</li>
</ul>
</li>
<li><a href="#">no target</a></li>
</ul>
Thanks, Max
Upvotes: 1
Views: 170
Reputation: 625097
$(":not(:only-child)")
See jquery selectors. The definition of :only-child
is:
Matches all elements that are the only child of their parent.
Upvotes: 4