Show/Hide DIV based on Form Checkbox
Show and/or Hide a Div based on a form checkbox selection.
HTML
<input type="checkbox" name="MyCheckBox" id="MyCheckBox1" />
<input type="checkbox" name="MyCheckBox2" id="MyCheckBox2" />
<input type="text" placeholder="1" id="input1">
<input type="text" placeholder="2" id="input2" style="display: none">
JavaScript
$('#MyCheckBox1').click(function() {
if ($(this).is(':checked')) {
$("#ShowMeDIV").show();
} else {
$("#ShowMeDIV").hide();
}
});
$('#MyCheckBox2').click(function() {
if ($(this).is(':checked')) {
$("#ShowMeDIV").show();
} else {
$("#ShowMeDIV").hide();
}
});