Can someone help me figure out how to change the background color of my card element when a radio button is selected?
<div class="col-6 col-md-3 mt-4 text-center my-auto">
<label for="'.$abreviation.'">
<div class="card card-block d-flex">
<div class="card-body align-items-center d-flex justify-content-center">
<input type="radio" id="'.$abreviation.'" name="tri" value="'.$abreviation.'" class="check-on" /> '.$tri.'
</div>
</div>
</label>
</div>
Is there a way to do this using only CSS, or do I need to use JavaScript or jQuery? I attempted it myself, but all the cards end up with a red background instead of just the selected one.
$(document).ready(function(){
$(".check-on").click(function(){
$('.check-on').parent().parent().addClass('backgroundCard')
});
});
Thank you in advance for your assistance.