JSFiddle - React, Tailwind, and code Playground
by csornmo
HTML
<div class="customer">
<input customer="customerA" city="New York" type="number" value="1">
<input customer="customerA" city="London" type="number" value="1">
<input customer="customerA" city="Paris" type="number" value="1">
</div>
<div class="customer">
<input customer="customerB" city="New York" type="number" value="1">
<input customer="customerB" city="London" type="number" value="1">
<input customer="customerB" city="Paris" type="number" value="1">
</div>
<div class="customer">
<input customer="customerC" city="New York" type="number" value="1">
<input customer="customerC" city="London" type="number" value="1">
<input customer="customerC" city="Paris" type="number" value="1">
</div>
JavaScript
var postData = [];
$('.customer input').each(function() {
var customer = $(this).attr('customer');
var city = $(this).attr('city');
var quantity = $(this).text();
//console.log(kund, mottplats, antal);
tmp = [{
'customer': customer,
"city": {
'name': city,
'quantity': quantity
}
}]
postData.push(tmp);
});
console.log(tmp)