(continue from other question)
<div id="main">
<div class="a">aaaa</div>
<div class="b"><p>not me</p></div>
<div class="b">bbbb</div> <!-- select this-->
<div class="b">bbbb</div> <!-- select this-->
<div class="c">cccc</div>
</div>
I'm trying to select all divs with class b
that doesn't have <p>not me</p>
inside of them.
I tried this:
$('div.b:not(:has(p:contains(not me)))').css('color', 'red');
But from some unknown reason it doesn't work, funny thing is, that if I remove the :not()
part:
$('div.b:has(p:contains(not me))').css('color', 'blue');
It does select the unwanted div, so the problem must be with :not
I know there are other and even better ways,(I even gave some in that question) but I'm interested to know why :not
+ :contains
doesn't seem together.