How can I select elements (using jQuery) that do not contain any elements?
For example, in the following tree:
<div class="a">
<div class="b">
<div class="c"></div>
</div>
<div class="d"></div>
<div class="e">Lorem</div>
</div>
Only the <div>s with class c, d, and e will be selected.
LIVE DEMO
If you want to do it with the
filterfunction, be aware that> elementwill be deprecated in next jQuery versions!you can use this:
:emptyselector won’t work here because there is text node in the<div class="e">use
:emptyselector:docs: