I have a table of elements, each of which has a checkbox for selecting or exiting. Since the list of items can be very long, I want to offer a “global” checkbox to check all checkboxes or disable them according to the setting of this global checkbox. I created jQuery code that does just that, but unfortunately, only once. I can’t switch settings again and again. Any thoughts why? Thank!
Here is my code:
jQuery('#ci-firmware-assign-toggle-checkbox').click(function(){
if(jQuery('#ci-firmware-assign-toggle-checkbox').is(":checked")) {
jQuery('tbody .ci-firmware-assign-checkbox').each(function(){
if(!jQuery(this).attr("checked")) {
jQuery(this).attr('checked', true);
};
});
} else {
jQuery('tbody .ci-firmware-assign-checkbox').each(function(){
if(jQuery(this).attr("checked")) {
jQuery(this).attr('checked', false);
};
});
}
});
source
share