How can I check if a checkbox in a checkbox array is checked using the id of the checkbox array?
I am using the following code, but it always returns the count of checked checkboxes regardless of id.
function isCheckedById(id) {
alert(id);
var checked = $("input[@id=" + id + "]:checked").length;
alert(checked);
if (checked == 0) {
return false;
} else {
return true;
}
}
Best Answer
That gets if the checkbox is checked.
For an array of checkboxes with the same name you can get the list of checked ones by:
Then to loop through them and see what's checked you can do:
To find how many are checked you can do: