如何创建一个jQuery选择器来选择所有类名为“foo”的元素,除了那些只有类名为“bar”的子元素的那些元素。
<!-- Don't select this -->
<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 this -->
<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 this -->
<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 this -->
<div class="foo">
<p>Some text</p>
</div>
答案 0 :(得分:2)