select根据后台的值默认选中
1:首先把值传给input
<input type="hidden" id="ManagementRole1" >
<select class="form-control" id="ManagementRole" name="ManagementRole">
<option value="总经理" >总经理</option>
<option value="财务主管">财务主管</option>
<option value="值班经理">值班经理</option>
<option value="出入场员">出入场员</option>
<option value="售货员">售货员</option>
<option value="鞋柜管理人员">鞋柜管理人员</option>
<option value="售票员">售票员</option>
<option value="课程顾问">课程顾问</option>
</select>
然后进行赋值:
modal.find('.modal-body input#ManagementID').val(management.managementID); modal.find('.modal-body input#ManagementName').val(management.managementName); modal.find('.modal-body input#ManagementRole').val(management.managementRole); modal.find('.modal-body input#ManagementRole1').val(management.managementRole); modal.find('.modal-body input#ManagementPhone').val(management.managementPhone); modal.find('.modal-body input#ManagementPass').val(management.managementPass); modal.find('.modal-body input#pageindex').val(pageindex); var role=$("#ManagementRole1").val() $("#ManagementRole option[value='"+role+"']").attr("selected","selected")
参考网站:https://blog.csdn.net/eluanshi12/article/details/78676861