场景

在Jquery中遍历多选框,获取属性为checked即被选中的input的value。

实现

function printDetails(){
debugger
var checkID = [];//定义一个空数组
$("input[name='checkedid']:checked").each(function(i){//把所有被选中的复选框的值存入数组
checkID[i] =$(this).val();
console.log(checkID);
});
$.ajax({
type: 'POST',
url: "/wmsReceiveOrder/doPrintDetailsPostRequest",
cache: false, //禁用缓存
data:JSON.stringify({"id":checkID}),
contentType: "application/json",
dataType: "json",
async:true,
success: function (result) {
debugger
alert(result.message)
}
})
}