Home >Web Front-end >Layui Tutorial >How to backfill the value selected in layui drop-down
If you want to know more about layui, you can click: layui tutorial
##layui gets the value in the check box and backfills
layui gets the value in the check box (get multiple, separated by commas)
let zxbm= document.getElementsByName("zxbm"); let check_val = []; for(k in zxbm){ if(zxbm[k].checked) check_val.push(zxbm[k].value); } let zxbmcheck=check_val.join(",");
layui checkbox backfill
var apv = res.data.zxyj.split(","); //将数据以,(逗号)分割形成数组(res.data.zxyj是从后台获取到的数据(形如:1,2,3)) $("[name=zxbm1]:checkbox").prop("checked", false); if(apv != "") { for(var i = 0; i < apv.length; i++) { $("[name=zxbm1][value=" + apv[i] + "]").prop("checked", true); } }
The above is the detailed content of How to backfill the value selected in layui drop-down. For more information, please follow other related articles on the PHP Chinese website!