我正在尝试在 div 中显示/隐藏表单,以多个复选框为条件。如果所有 3 个都被选中,则应该出现 div 内容。如果一个或多个未选中,则应该隐藏 div 内容。
<!DOCTYPE html>
<html lang="en">
<head>
<link href="style/bootstrap.css" rel="stylesheet">
<script src="js/jquery.js"></script>
<script>
if ($('#checkbox1, #checkbox2, #checkbox3').is(:checked)) {
$('#purchaseForm').show();
} else {
$('#purchaseForm').hide();
}
</script>
</head>
<body>
<div class="span6">
I understand that...<br>
I understand that...<br>
I understand that...<br><br>
<div id="purchaseForm">
[form]
</div>
</div>
<div class="span6">
<input name="checkbox1" id="checkbox1" value="" type="checkbox"><br>
<input name="checkbox2" id="checkbox2" value="" type="checkbox"><br>
<input name="checkbox3" id="checkbox3" value="" type="checkbox"><br>
</div>
</body>
</html>