从活动div中删除子类[重复](Remove child class from active div [duplicate])
这个问题在这里已有答案:
如何在jQuery中选择具有多个类的元素? 11个答案我有一个问题是只从活动div中删除img类:
<div class="thumb thumb-selected"> <img class="img-thumb BWFilter BWfade" src="100x100.jpg" alt=""><img crossorigin="anonymous" style="height: 100px; width: 100px; margin-top: 0px; margin-left: 0px;" class="img-thumb" src="3-100x100.jpg" alt=""></div>我想删除(BWFilter BWfade)类,只为这个div(.thumb .thumb-selected),我正在尝试使用这个jquery代码:
$('.thumb .thumb-selected').find('.img-thumb img').removeClass("BWFilter BWfade");This question already has an answer here:
How can I select an element with multiple classes in jQuery? 11 answersI have a problem to remove only img class from active div :
<div class="thumb thumb-selected"> <img class="img-thumb BWFilter BWfade" src="100x100.jpg" alt=""><img crossorigin="anonymous" style="height: 100px; width: 100px; margin-top: 0px; margin-left: 0px;" class="img-thumb" src="3-100x100.jpg" alt=""></div>I want to remove (BWFilter BWfade) class, only for this div (.thumb .thumb-selected), I'm trying with this jquery code:
$('.thumb .thumb-selected').find('.img-thumb img').removeClass("BWFilter BWfade");最满意答案
removeClass接受多个要删除的类:
$('.thumb.thumb-selected > img.img-thumb').removeClass('BWFilter BWfade');> - 选择器仅在img是div的直接子项时才匹配。
参考
.removeClass()
css - 子选择器
the removeClass accepts more then one class to remove:
$('.thumb.thumb-selected > img.img-thumb').removeClass('BWFilter BWfade');The > - selector will only match when the img is a direct child of your div.
Reference
.removeClass()
css - child-selector
更多推荐
发布评论