下拉选渲染有很多方式,这个比较简单,记录一下;
HTML代码如下:
<div class="layui-input-inline"> <input type="hidden" id="check_status" value="${entity.check_status }"> <select name="document_status" id="document_status" disabled> <option value="0">编辑</option> <option value="1">送审</option> <option value="2">已审</option> <option value="3">驳回</option> </select> </div>
JS渲染:
var status = $("#check_status").val(); $("#document_status option[value=" + status + "]").attr('selected', 'selected'); form.render('select');
注意:
Layui的话一定要加上:form.render('select');
附一下我之前的写法(比较麻瓜繁琐):
var optionstring = ""; optionstring += "<option value="" + value + "" >" + name + "</option>"; $("#roleSelect").html('<option value="">请选择</option>' + optionstring); form.render('select');