ID在您的文档中必须是唯一的,这意味着您不应该这样做:
<input type="check@R_69_2419@" name="chk[]" id="chk[]" value="Apples" />
<input type="check@R_69_2419@" name="chk[]" id="chk[]" value="Bananas" />
<fieldset id="checkArray">
<input type="check@R_69_2419@" name="chk[]" value="Apples" />
<input type="check@R_69_2419@" name="chk[]" value="Bananas" />
</fieldset>
现在是jQuery:
var atLeastOneIsChecked = $('#checkArray:check@R_69_2419@:checked').length > 0;
//there should be no space between identifier and selector
// or, without the container:
var atLeastOneIsChecked = $('input[name="chk[]"]:checked').length > 0;
$('#' + id).is(":checked")
如果选中此复选框,则可以得到。
对于具有相同名称的复选框数组,您可以通过以下方式获取已选中复选框的列表:
var $@R_69_2419@es = $('input[name=thename]:checked');
然后遍历它们并查看已检查的内容,您可以执行以下操作:
$@R_69_2419@es.each(function(){
// Do stuff here with this
});
要查找已检查的数量,您可以执行以下操作:
$@R_69_2419@es.length;