Javascript 未在UI中启用html选择

Javascript 未在UI中启用html选择,javascript,jquery,asp.net,webforms,Javascript,Jquery,Asp.net,Webforms,我有这个html代码 <td width="300px"> <select id="Drpdwn_application2" name="Drpdwn_application2" ClientIDMode="static" class="multiselect" runat="server"> </select> </td

我有这个html代码

<td width="300px">
     <select id="Drpdwn_application2" 
             name="Drpdwn_application2" 
             ClientIDMode="static" 
             class="multiselect" 
             runat="server">
      </select>
</td>
其他一些声明:

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" type="text/javascript"></script>
    <script src="js/capability.js" type="text/javascript"></script>
    <script src="scripts/jquery-ui-1.10.3.js" type="text/javascript"></script>
    <link href="Content/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
    <script src="style/bootstrap/js/bootstrap-multiselect.js" type="text/javascript"></script>
这里,

这是为了启用选择

 $('#Drpdwn_application2').prop('disabled', false);
要禁用选择,请使用

 $('#Drpdwn_application2').prop('disabled', 'disabled');
试试这个

Javascript


函数禁用(){
document.getElementById(“mySelect”).disabled=true;
}
函数启用(){
document.getElementById(“mySelect”).disabled=false;
}
你的HTML


苹果
梨
香蕉
橙色

在您的备选方案中,您是指“Drpdwn”应用程序3而不是“Drpdwn”应用程序2吗?@AndrewShepherd抱歉,这是一个输入错误:)更新了问题。您是否尝试将其禁用或启用?这是无效的HTML;td元素不能单独存在,它必须始终有它的祖先,一直到
。否则会有奇怪的行为。@user3558931它在
alert(document.getElementById("Drpdwn_application2").disabled);
// return true/false
// which i think is working
// but the control in the UI is not updating
 $('#Drpdwn_application2').prop('disabled', false);
 $('#Drpdwn_application2').prop('disabled', 'disabled');
<script>
function disable() {
    document.getElementById("mySelect").disabled=true;
}
function enable() {
    document.getElementById("mySelect").disabled=false;
}
</script>
<select id="mySelect">
  <option>Apple</option>
  <option>Pear</option>
  <option>Banana</option>
  <option>Orange</option>
</select>
<input type="button" onclick="disable()" value="Disable list">
<input type="button" onclick="enable()" value="Enable list">