mistero
mistero

Reputation: 5309

Target all x elements with sibling y

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

Answers (1)

cletus
cletus

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

Related Questions