Skip to content

Instantly share code, notes, and snippets.

@1-800-jono
Created April 12, 2018 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1-800-jono/1412d64f825f5e91b3da2e965bf3fc5f to your computer and use it in GitHub Desktop.
Save 1-800-jono/1412d64f825f5e91b3da2e965bf3fc5f to your computer and use it in GitHub Desktop.
Add all checkbox checked values to array using jQuery
//We need the window to load completely before using this function
jQuery(window).load(function() {
jQuery('.some-form').submit(function (e) {
e.preventDefault();
var checkedProfessions = jQuery('.checkbox-container input:checkbox:checked').map(function() {
return jQuery(this).val();
}).get(); //Converts to array
console.log(checkedProfessions);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment