如下形式:
<form action="x.php" method="get" id="myForm">Subscribe:
<div id="radioButtonsWithAdds">
<input type="radio" name="group1" value="one">One month 2,99$
<input type="radio" name="group1" value="two"> Two months 5,98$</div><br>
<input type="checkbox" name="option1" value="withAdds" checked> with adds
<img src="next.png" border="0" alt="enviar" onclick="document.getElementById('myForm').submit();">
</form>
是订阅的第一部分。在这里,用户可以选择一个月或两个月的订阅。
如果用户同意接收添加,并选中复选框,就这样,他/她可以点击下一步按钮,就可以了。
但是,如果用户取消选中“添加”复选框,则 #radioButtonsWithAdds 的位置将显示一个 div,其中包含另一组具有不同价格的单选按钮。
如何在不点击任何提交按钮的情况下检测复选框是否已选中?
最佳答案
$('#yourcheckbox').change(function() {
if ( ! this.checked) {
// It is not checked, show your div...
}
});
关于jquery - 如何检测用户是否取消选中复选框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4816145/