Do something if the checkbox is checked
Demo
CheckBox1Do something if two checkboxes are checked
CheckBox2 CheckBox3 CheckBox4HTML
<!-- If one checkbox is checked -->
<input type="checkbox" id="check1"/>CheckBox1
<!-- If two checkboxes are checked -->
<input type="checkbox" id="check2"/>CheckBox2
<input type="checkbox" id="check3"/>CheckBox3
<input type="checkbox" id="check4"/>CheckBox4
Script
<script>
/* If one checkbox is checked */
$('#check1').click(function () {
if (jQuery(this).is(':checked')) {
alert("checked");
} else {
alert("unchecked");
}
});
/* If two checkboxes are checked */
$("input[type=checkbox]").change(function(){
if($('#check2').is(':checked') && $('#check3').is(':checked')) {
alert("You checked 2 and 3");
}
else if($('#check2').is(':checked') && $('#check4').is(':checked')) {
alert("You checked 2 and 4");
}
else if($('#check3').is(':checked') && $('#check4').is(':checked')) {
alert("You checked 3 and 4");
}
});
</script>