js 获取 checkbox[] 值
$("#btnAdd1").click(function () { console.log($("form").serialize()); var checkboxs = document.getElementsByName("checkbox[]"); var check_val = []; for (var i = 0; i < checkboxs.length; i++) { if (checkboxs[i].value == "") { continue; } check_val.push(checkboxs[i].value); } if (check_val.length<1) { layer.msg("请选择数据!"); } });
var data2 = getcheckbox("check2"); if (data2.length < 1) { // alert("请选择数据!"); layer.msg("请选择数据!"); return; } var result1 = data1 + ""; 结果 是以逗号分开的字符串