52,787
社区成员
发帖
与我相关
我的任务
分享

var d = { enterpriseId: $('#eId').val(), cardTypeId: 666, foodPriceList: [] }
$('tr[id="trPrice"]').each(function () {
var ipts = $('input', this);
if (/^\d+(\.\d+)?$/.test(ipts[2].value)) {//价钱输入了数字
d.foodPriceList.push({ foodId: parseInt(ipts[1].value, 10), price: parseInt(ipts[2].value, 10) });
}
});
console.log(d)///
console.log(JSON.stringify(d))//转为json字符串