Checking (and unchecking) all Checkboxes with JQuery
I’ve seen a lot of unnecessary code recently when it comes to JQuery. Anyway. If you wish to check (tick) or uncheck (untick) all checkboxes with JQuery use the find, each and attr functions. This will loop through every checkbox element and set the attribute you want.
Example of checking every checkbox:
1 2 3 | $("#div").find("input[type='checkbox']").each(function(){ $(this).attr('checked', true); }); |