Whenever I click the label that is inside flags it should apply a background-color . It's working. What happens, is that when I click on a div, it applies the background correctly, but when I click on another, I want it to remove the background-color from the previous div and leave it applied only to the current one.
$('.bandeiras label').click(function() {
$(this).css('background-color', '#8a8383');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divclass="bandeiras cf">
<label for="codigoBandeiraV" class="cc-radio" style="background-color: rgb(138, 131, 131);">
<input type="radio" id="codigoBandeiraV" name="codigoBandeira" value="visa">
<img src="/assets/images/cartoes/visa.png" alt="Visa" title="Visa" align="absmiddle"></label>
<label for="codigoBandeiraM" class="cc-radio" style="background-color: rgb(138, 131, 131);">
<input type="radio" id="codigoBandeiraM" name="codigoBandeira" value="master"><img src="/assets/images/cartoes/mastercard.png" alt="MasterCard" title="MasterCard" align="absmiddle"></label>
<label for="codigoBandeiraDin" class="cc-radio" style="background-color: rgb(138, 131, 131);"><input type="radio" id="codigoBandeiraDin" name="codigoBandeira" value="diners"><img src="/assets/images/cartoes/dinners.png" alt="Diners" title="Diners" align="absmiddle"></label>
<label for="codigoBandeiraE" class="cc-radio" style="background-color: rgb(138, 131, 131);"><input type="radio" id="codigoBandeiraE" name="codigoBandeira" value="elo""><img src="/assets/images/cartoes/elo.png" alt="Elo" title="Elo" align="absmiddle"></label>
</div>