Skip to content

Instantly share code, notes, and snippets.

@badcrocodile
Created August 6, 2014 14:23
Show Gist options
  • Save badcrocodile/24d338b1d81c9efbf934 to your computer and use it in GitHub Desktop.
Save badcrocodile/24d338b1d81c9efbf934 to your computer and use it in GitHub Desktop.
map a group of checkboxes into an array in three lines of jquery
// Find all of the checked boxes in the container and map them into an array
var searchIDs = $checkboxContainer.find('input:checkbox:checked').map(function() {
return $(this).val();
}).get();
// searchIDs is now an array containing the values of the checked boxes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment