Jquery: selecting elements that do not only have children with the same class name? -
how make jquery selector selects elements class name "foo", except have children class name of "bar".
<!-- don't select --> <div class="foo"> <div class="bar"></div> <div class="bar"></div> <div class="bar"></div> <div class="bar"></div> <div class="bar"></div> </div> <!-- don't select --> <div class="foo"> <div class="bar"><p>some text</p></div> <div class="bar"></div> <div class="bar"></div> <div class="bar"><p>some text</p></div> <div class="bar"></div> </div> <!-- select --> <div class="foo"> <p>some text</p> <div class="bar"></div> <div class="bar"></div> <div class="bar"></div> <div class="bar"></div> </div> <!-- select --> <div class="foo"> <p>some text</p> </div>
something this?
$('.foo > :not(.bar)').closest('.foo');
start .foo
, find immediate children except have bar
class, , revert .foo
.