Skip to content

Instantly share code, notes, and snippets.

@gshutler
Created March 15, 2010 15:39
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 gshutler/332960 to your computer and use it in GitHub Desktop.
Save gshutler/332960 to your computer and use it in GitHub Desktop.
var elementsToHash = function(elements) {
var hash = {};
elements.each(function() {
var element = $(this);
hash[element.attr("name")] = element.val();
});
return hash;
}
/* Example usage - could make this a jQuery plugin */
var stuff = $("input.stuff");
var stuffAsHash = elementsToHash(stuff);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment