Created
April 12, 2018 14:37
-
-
Save 1-800-jono/1412d64f825f5e91b3da2e965bf3fc5f to your computer and use it in GitHub Desktop.
Add all checkbox checked values to array using jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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