views:

57

answers:

3

How to query child containers, and not inside containers (thats not about attributes)

<div class="container">
   <div>
      <div class="container" child>
           <div>
              <div class="container" inside>
   <div>
      <div class="container" child>
           <div>
              <div class="container" inside>
</div>

Edit: Maybe I can use, something like not()?

.container not(.container)?

A: 

$("div.container > div").find("div.container:first");

Chad Grant
By the div, I mean that I dont know = what can be there
dynback.com
I don't understand your comment.
Chad Grant
A: 

You need to have something to anchor the class selection to a particular div. I suggest giving the outer one a name. Then you can find the outer one by name and it's children using the children method with the class filter.

$('#outerDiv').children('.container');
tvanfosson
+3  A: 

I could be missing the point, but I think something in the lines of:

$(".container .container:not(.container .container .container)")

I.e., all elements who is a "container inside a container" but not those that are a "container in a container in a container".

waxwing