Any changes to the input element through the script do NOT fire the onchange
event.
Alternatively, you can run change()
when updating the input, as shown below,
$(this).prop("checked", status).change();
Full code:
function toggleChecked(status) { $(".chkbx").each( function() { $(this).prop("checked", status).change(); }); }
Also use .prop
instead of .attr
Demo
source share