I want a reaction when all three checkboxes are checked, but not when even one isn't checked.
Sample:
"#cBox1, #cBox2, #cBox3 are checked = Consol.log('checked');"
"Just #cBox1, #cBox3 are checked = Consol.log('NOT checked');"
I've already tried the following, without the right result: if($('#cBox01, #cBox02, #cBox03')
<div id="cBoxes">
<form>
<input id="cBox01" class="cBox" type="checkbox" name="cBox01" value="cBox01"> checkbox 1<br>
<input id="cBox02" class="cBox" type="checkbox" name="cBox02" value="cBox02"> checkbox 2<br>
<input id="cBox03" class="cBox" type="checkbox" name="cBox03" value="cBox03"> checkbox 3<br>
</form>
</div>
$('.cBox').change( function(){
if($('#cBox01' && '#cBox02' && '#cBox03').is(':checked')){
console.log('checked');
}else {
console.log('NOT checked');
}
});
I got the right result after #cBox3 is checked but just for this one and not for all of them.
Aucun commentaire:
Enregistrer un commentaire