我正在尝试编写一个选择器,只有当他们的孩子不包含以下3个班级时才选择<div>
和class="my-rating"
。
示例html:
<div class="my-rating" id="parentA">
<div class="foo"></div>
</div>
<div class="my-rating" id="parentB">
</div>
<div class="my-rating" id="parentC">
<div class="rating-full-star"></div>
<div class="rating-full-star"></div>
<div class="rating-full-star"></div>
<div class="rating-half-star"></div>
<div class="rating-empty-star"></div>
<div class="bar"></div>
</div>
<div class="my-rating" id="parentD">
<div class="rating-full-star"></div>
<div class="rating-full-star"></div>
<div class="rating-full-star"></div>
<div class="rating-half-star"></div>
<div class="rating-empty-star"></div>
</div>
我想选择parentA
和parentB
并排除C和D.
这样的事情:
$('.my-rating').children().filter(':not(.rating-full-star):not(.rating-half-star):not(.rating-empty-star)')
除了这个家伙抓住所有孩子,而不是父母。我也尝试过:
$('.my-rating :not(.rating-full-star,.rating-half-star,.rating-empty-star)')
但这并没有抓住太多的东西。我能在这做什么?
答案 0 :(得分:1)
你在这里:
$('.my-rating').not(':has(.rating-full-star, .rating-half-star, .rating-empty-star)');