js中如何将使用js的方法获取的input的值的结果转化为对象?例如:<input type="hidden" name="upload_pic" class="upload_pic" value="123"><input type="hidden" name="upload_pic" class="upload_pic" value="456"><input type="hidden" name="upload_pic" class="upload_pic" value="789">var upload_pic = [];document.getElementsByName('upload_pic').forEach(pic => { upload_pic.push(pic.value);});以上获取的upload_pic结果是:[ "8d448a4151a74492b360c80f11c0a705", "4713c6c87cf142b98c7b688f807d2162", "5112a1e0f5cd408bb12372f64eff9b51"]请问如何将其转化为对象,可以使用jQuery ajax进行提交?因为我发现直接使用这个貌似java无法接到值
2 回答
BIG阳
TA贡献1859条经验 获得超6个赞
var obj = {};
obj.upload_pic = [];
document.getElementsByName('upload_pic').forEach(pic => {
obj.upload_pic.push(pic.value);
});
添加回答
举报
0/150
提交
取消