如何检测用户已取消选中复选框? [英] How to detect that a user has unchecked a checkbox?
本文介绍了如何检测用户已取消选中复选框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下表单:
<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>
是订阅的第一部分。在这里,用户可以在一个月或两个月之间选择订阅。
Is the first part of a subscription from. In here, the user may choose between one month or two months subscription.
如果用户同意接收添加,则选中复选框,这将是所有,他/她可以点击下一个按钮,这是确定。
If the user agrees to receive adds, leaves the checkbox checked, that will be all, he/she can hit the next button and it's ok.
但如果用户取消选中添加复选框,则div将显示在#radioButtonsWithAdds的位置,其中包含另一组具有不同价格的单选按钮。
But if the user unchecks the "with adds" checkbox, a div will show in the place of the #radioButtonsWithAdds one containing another set of radio buttons with different prices.
如何检测复选框ish而不触及任何提交按钮?
How can I detect that the checkbox ish without hitting any submit button?
推荐答案
$('#yourcheckbox').change(function() {
if ( ! this.checked) {
// It is not checked, show your div...
}
});
这篇关于如何检测用户已取消选中复选框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文