tags:

views:

35

answers:

1

Hi, 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

+4  A: 
$(":not(:only-child)")

See jquery selectors. The definition of :only-child is:

Matches all elements that are the only child of their parent.

cletus
nice and easy approach! :D thanks!
mistero