SO jQuery 1.5.1 Fiddle
Test Fiddle mainly for SO Questions jQuery 1.5.1, UI 1.9
by Nick Craver
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/ui-lightness/jquery-ui.css">
JavaScript
var fields = {
account_id_ : {
name : "test",
width : 60,
elm : $('<input class="inp" type="text" style="text-align:right" />'),
value : '',
focus : true
},
name : {
name : "test",
width : null,
elm : $('<input class="inp" type="text" />'),
value : ''
}
};
var newFields = $.extend(true, {}, fields);
//Comment out the below line of code to see only 2 fields, not 4 from the 2 copies
$.each(newFields, function(n, f) { f.elm = f.elm.clone(); });
for(var f in fields) {
$("body").append(fields[f].elm);
}
for(var f in newFields) {
$("body").append(newFields[f].elm);
}