I am looking for jQuery slector that will find all descendants of passed jQuery object that are not nested in any element that fits same selector. Consider following HTML:
<body>
<div class="container" id="1">
<div class="container" id="11"></div>
<div class="container" id="12"></div>
</div>
<div class="container" id="2"></div>
<div class="noncontainer">
<div class="container" id="3">
<div class="container" id="31"></div>
</div>
</div>
</body>
In this example $("body").find(".container magicSelector")
should return divs 1, 2 and 3. $("#1").find(".container magicSelector")
should return divs 11 and 12.
EDIT: I have wrote a function for that here, but I think that selector would be cleaner and faster.