cblPeriods是checboxlist控件的标识。下面的注释行不起作用,我不确定它为什么不能与chkboxes对象一起工作。但是,当我使用jquery选择器时,注释行下方的行工作正常。CheckboxList - 根据obj数组中的值勾选复选框
请建议为什么我无法使用chkboxes obj。我附上了萤火虫的监视窗口截图。声明
$(chkboxes[value=-1]).prop("checked", false);
不会产生任何对象...
$(function() {
$('#cblPeriods').find(":checkbox").on("click", function() {
var $obj = $(this);
var selVal = $obj.val();
var chkboxes = $('#cblPeriods').find(":checkbox");
if (selVal == '-1') { //No
$(chkboxes).not($obj).removeAttr("checked");
}
else if (selVal == '0') { //All
$(chkboxes).not($obj).prop('checked', true);
//$(chkboxes).find(":checkbox[value=-1]").removeAttr("checked"); //THIS ONE IS NOT WORKING..
$('#cblPeriods').find(":checkbox[value=-1]").removeAttr("checked");
}
});
});
过滤器的工作原理:-),看起来更好.. – Karan