DEV Community

Discussion on: Select All Checkboxes with jQuery

Collapse
 
jackharner profile image
Jack Harner πŸš€

Updated my pen to do this. Basically on click of any checkbox, if the "checked" prop is false, uncheck the Select All Checkbox.

$("input[type=checkbox]").click(function() {
    if (!$(this).prop("checked")) {
        $("#selectAll").prop("checked", false);
    }
});
Enter fullscreen mode Exit fullscreen mode

Now if you were looking to also check the Select All box when everything gets checked, you'd have to on click, find all the other check boxes, see if they're all checked and set the Select All box accordingly.

Collapse
 
64ost profile image
Tonistack

Thanks

Collapse
 
vandygawade profile image
vandy7

I've been trying but I couldn't implement it can you please provide me the source code or explain it with an example.