I need to loop through the all checkboxs to set the button disable or not. If one of the checkbox is checked, then the button is enable. However it looks like my code didn't loop through the checkbox. The alert inside the each function doesn't shown.I found the looping method on How to loop through group of check boxes that have same class name?
There is my code:
function setButton() {
alert('line 24');
var blnDisable = true;
//https://stackoverflow.com/questions/35506843/how-to-loop-through-group-of-check-boxes-that-have-same-class-name
$('.chkItem').each(function (index, obj) {
if (obj.checked == true) {
alert('line 30');
blnDisable = false;
}
});
alert('disable=' + blnDisable);
$("#btnDownload").attr("disabled", blnDisable);
}
objwill be a jQuery object - jQuery objects don't have acheckedproperty - use an instance ofthis-if (this.checked)objwill be an HTML element. @op When is setButton called?if(obj.prop("checked"))