vendredi 30 décembre 2016

Div changes background color when checkbox is checked

I'm still learning jquery and how to put it all together but I have this code set up in a shopping list:

<div class="AddCheckedWrapper">
    <span>Check to Add to Cart</span>
    <input name="atcuid" type="checkbox">
</div>

How I want this to work is that clicking .AddCheckedWrapper checks the checkbox and clicking it again unchecks it. Then, if the box is checked .AddCheckedWrapper background changes to blue. And if it's not checked then .AddCheckedWrapper background changes pink. The issue I'm having though is that since it's a list, there's more than one .AddCheckedWrapper so I know $(this) will have to be used somehow. I also have a quantity box that'll check the checkbox if you change what's in it. So if I change the number in the quantity box no matter it'll check the checkbox. So the background colors have to be in effect based off of the check box being checked or not, and that's where I'm having trouble.




Aucun commentaire:

Enregistrer un commentaire