I have a list of checkboxes and i have a select_all checkbox. Please check the comment in the code.
$('#select_all').change(function() {
var checkboxes = $("input[name^='select']");
if($('#select_all').is(':checked')) {
//here i want to check where this checkbox (checkbox from the list not select_all checkbox) is visible or not.
// if visible then check the checkbox
checkboxes.attr('checked', 'checked');
} else {
checkboxes.removeAttr('checked');
}
});
Is there any think like this to check the visibility:–
$("input[name^='select'][checked]").each(
function() {
// Insert code here
}
);
Use the :visible selector.
Note how I’ve used the correct method of setting the
checkedattribute; the value should be a boolean, not a string.