I've been trying to update results based off of how many checkboxes a user has checked on a page.
If the user has checked 5 or more then it should fade 2 divs.
If the user has checked 10 or more it should fade another two divs.
If the user chooses 10 or more it should fade another set.
I can get the first function to run but I believe since the first if statement has been completed, it's not looking for updates/value changes? The others do not fade back to 100% opacity either.
$('input:checkbox').change(function() {
var boxChecked = $('input:checkbox:checked').length;
if (boxChecked > 5) {
$('.div-1, .div-2').fadeTo(500, 0.4)
}
else if (boxChecked > 10) {
$('.div-1, .div-3').fadeTo(500, 0.4)
}
else if (boxChecked > 11) {
$('.div-1, .div-2').fadeTo(500, 0.4)
}
});
div-3and thediv-2in the 2nd and 3rdfadeTostatements, respectively, are both missing the.class selector. Is this intended?boxChecked >= 5style for all your ifs, since you said "if the user has checked 5 or more".boxChecked > 5means the code won't be run unless the user has 6 or more boxes checked.