tags:

views:

122

answers:

1

For example we have such dom:

<div id="main" class=".container">
    any other elements
    <div>
       <span class="edit" />
    </div>
    <div class=".container">
         <div class="edit">
    </div>
</div>

How to make query, to select only first edit

Something like $('#main .edit:not(.container between)')

+1  A: 

It's rather confusing when the outer container is also of class "container".

This works:

$('#main .edit:not(#main .container .edit)')

If your outer div doesn't have the "container" class:

$('#main .edit:not(.container .edit)')

(note: you shouldn't use class=".container", but class="container")

Philippe Leybaert
I don't see why it would break if there is more than one layer of nesting. The selector ".container .edit" matches any "edit" class below a "container" class, no matter how deeply nested.
Philippe Leybaert