有没有人知道我是怎么来的:
var guests = [];
for (var i = 0; i < parseInt(apartments) ; i++) {
var pos = i + 1;
var adults, children, infants;
adults = $("#adults" + pos).val();
infants = $("#infants" + pos).val();
children = $("#children" + pos).val();
guests.push({ Leg: pos, Adults: adults,
Children: children, Infants: infants
});
}
对于这样的事情:
Guests: [{ Leg: "1", Adults: "2", Children: "0", Infants: "2" },{ Leg:
"2", Adults: "2", Children: "1", Infants: "0" }]