听到我的代码:
<div class="reminderDiv">
<input type="checkbox" class="require-one" id="lmrText" name="lmrText"><label>Text Message</label>
<input type="checkbox" class="require-one" id="lmrPhone" name="lmrPhone"><label>Phone</label>
<input type="checkbox" class="require-one" id="lmrEmail" name="lmrEmail"><label>Email</label>
</div>
使用JQuery,如何确定是否至少选中了一个复选框?
答案 0 :(得分:2)
$(".reminderDiv :checked").length > 0
如果选中至少一个复选框,则为true
。
答案 1 :(得分:2)
if($('.require-one:checked').length > 0)
{
// at least one checkbox was checked
}
else
{
// no checkbox was checked
}
答案 2 :(得分:0)
if($('input[type=checkbox]').is(':checked')==true) {
alert("Your data");
}
答案 3 :(得分:0)
if($('.require-one:checked').size() === 0){
{
//your code here
}