Skip to content

Instantly share code, notes, and snippets.

@RodrigoEspinosa
Created September 7, 2012 06:21
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 RodrigoEspinosa/3663781 to your computer and use it in GitHub Desktop.
Save RodrigoEspinosa/3663781 to your computer and use it in GitHub Desktop.
DOM to JSON parser for jQuery
function DOM2JSON(){
var Items = new Array;
$(".contenedor").each(function(index){
var label = $(this).children("label").text();
var type = $(this).children("input, textarea")[0];
var name = $(this).children("input, textarea").attr("name") || null;
var placeholder = $(this).children("input, textarea").attr("placeholder") || null;
Items.push(new Item(label, type, name, placeholder));
});
return Items;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment