Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove child class from active div [duplicate]

Tags:

html

jquery

I 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");
like image 870
Francesco De Pazzi Avatar asked Mar 03 '15 07:03

Francesco De Pazzi


1 Answers

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

like image 56
empiric Avatar answered Oct 12 '22 20:10

empiric