js:取复选框的值,
var payMethodName=$("input:checkbox[name='payMethod']:checked").map(function(index,elem) {
return $(elem).parent().text().trim();
}).get().join(',');
js:给前端 复选框 赋值
跳转页面先被值给当前端页面,在取值到js操作
var payMethod =$("#payMethod").val().split(","); var mapResult = payMethod.map(function(item,index,array){ return item-0; }); var divPayMethod=$("#divPayMethod").find("input[name=payMethod]"); for ( var i = 0; i <divPayMethod.length; i++){ for ( var j = 0; j <mapResult.length; j++){ if(divPayMethod[i].value ==mapResult[j] ){ var divInput=divPayMethod[i].id; $("#"+divInput+"").attr("checked",true); } } }