对于单纯的select,可以用disabled属性让其变成灰色不可选状态,用一下方法让其恢复可选:
$("#roleSelector").removeAttr("disabled");
class="easyui-combobox"
<select id="roleSelector" class="easyui-combobox" data-options="panelHeight:'auto',disabled:true" name="userInfo.role"> <option value=""></option> <option value="super">超级管理员</option> <option value="admin">普通管理员</option> <option value="user">普通用户</option> </select>
$(function(){ $("input[name='userInfo.admin']").click(function(){ var flag = $("input[name='userInfo.admin']:checked").val(); //$("#roleSelector").removeAttr("disabled"); //this method can not work if(flag=='true'){ //if this is admin,then roleSelect open ,otherwise it closed $("#roleSelector").combobox({ disabled:false }); }else{ $("#roleSelector").combobox({ disabled:true }); } }) })
$("#roleSelector").combobox({ disabled:false });