layui下拉框赋值
1、定义下拉框
<div class="layui-input-block layui-form" lay-filter="selFilter">
<select id="sel" lay-verify="required" >
<option value="">请选择</option>
<option value="A">选项A</option>
<option value="B">选项B</option>
</select>
</div>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
2、设置默认值:$(“#sel”).val(“B”);
3、渲染:form.render(‘select’,’selFilter’);
注:局部刷新需要使用lay-filter,并且设置class=”layui-form”
- var category = 0;
- var categoryName = ‘‘;
- form.on(‘select(
)‘, function (data) {selFilter
- category = data.value;
- categoryName = data.elem[data.elem.selectedIndex].text;
- form.render(‘select‘);
- });