Select All Checkboxes with jQuery

twitter logo github logo ・1 min read

A quick little jQuery snippet in order to select all checkboxes in a list of checkboxes.

$("#selectAll").click(function(){
        $("input[type=checkbox]").prop('checked', $(this).prop('checked'));

});

Basically, on Click of the Select All checkbox, set all checkboxes' checked property to the value of the Select All checkbox's checked property. That way you can select or deselect all.

twitter logo DISCUSS
Classic DEV Post from May 24

Follow Friday: What DEV member would you recommend following?

Jack Harner πŸš€ profile image
I'm Jack! I make websites. I specialize in custom WordPress solutions. Let's Chat!