-1

听到是我的代码:

<div class="reminderDiv">
    <input type="checkbox" class="require-one" id="lmrText"  name="lmrText"><label>Text Message</label>&nbsp;&nbsp;&nbsp;
    <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,我如何确定是否至少选择了一个复选框?

4

4 回答 4

2
$(".reminderDiv :checked").length > 0

这将是true如果至少一个复选框被选中。

于 2013-01-30T05:51:29.907 回答
2
if($('.require-one:checked').length > 0)
{
   // at least one checkbox was checked
}
else
{
  // no checkbox was checked
}

JSFIDDLE

于 2013-01-30T05:54:06.910 回答
0
if($('.require-one:checked').size() === 0){
{
    //your code here
}
于 2013-09-18T11:22:32.033 回答
0
if($('input[type=checkbox]').is(':checked')==true) {
    alert("Your data");
}
于 2013-01-30T05:51:58.963 回答