I have a simple quiz in which user can answer multiple questions, now when the user checks the box I am adding a class for the background.
Here is jsfiddle:demo
Here is function
// here we add event handler for newly created checkboxes.
nextQuestion.find("input[type='checkbox']").on('change', function () {
if ($(this).is(":checked")) {
//add checkbox background when is checked
$(this).addClass("input-before");
//uncheck the checkbox if another checkbox is checked
$('#next').prop("disabled", false);
$('input.cb').not(this).prop('checked', false, function(){
//remove the background ...this is not working
$(this).removeClass("input-before");
})
} else {
$('#next').prop("disabled", true);
$(this).removeClass("input-before");
}
});
Now when user check another checkbox the other checkbox is unchecked but the background is still there\
I want to remove the background when Unchecked.
what do I need to change to get this working?
:checkedproperty or"input-before"class. Try to unify this for now to have both - the tick and the background for the same 'state' and choose if you want this to be a class or a:checkedstate. Avoid mixing both of them.