badcrocodile
8/6/2014 - 2:23 PM

map a group of checkboxes into an array in three lines of jquery

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.