LayUI动态添加select下拉框中的选择项
data[{name:'aa',age:18},{name:'lisi',age:100},{name:'zhangsan',age:80}]
html
<div class='layui-col-md3'> <label class="layui-form-label">帅哥信息</label> <div class="layui-input-block"> <select id='aaa' lay-filter="aaa" class="layui-input " required="required"> </select> </div> </div>
js
//循环插入option数据数据
$.each(data, function(index, item) {
//赋值
$('#aaa').append(new Option(item.name, item.age));
});
//重新渲染select标签中的内容
layui.form.render("select");