如何启用或禁用列表框

时间:2015-06-19 04:15:04

标签: jquery asp.net plugins listbox

如何使用jQuery启用或禁用列表框控件?

HTML代码如下:

<div>
    <select size="4" name="ctl02$ddlCompensationDates" multiple="multiple" id="ctl02_ddlCompensationDates" disabled="disabled" class="chzn" style="width: 173px; display: none;">
        <option value="06/12/2015">06/12/2015</option>
        <option value="06/15/2015">06/15/2015</option>
        <option value="06/20/2015">06/20/2015</option>
        <option value="06/21/2015">06/21/2015</option>
    </select>
    <div class="chosen-container chosen-container-multi chosen-disabled" style="width: 173px;" title="" id="ctl02_ddlCompensationDates_chosen">
        <ul class="chosen-choices">
            <li class="search-field">
                <input type="text" value="Select Some Options" class="default" autocomplete="off" style="width: 149px;" disabled="">
            </li>
        </ul>
        <div class="chosen-drop">
            <ul class="chosen-results"></ul>
        </div>
    </div>
</div>

我尝试在ASP.NET页面中执行以下操作:

$('#<%= ddlCompensationDates.ClientID %>').attr('disabled', false); 
$('#<%= ddlCompensationDates.ClientID %>').focus(); 

1 个答案:

答案 0 :(得分:0)

我使用以下代码行解决了我的问题:

$('#<%= ddlCompensationDates.ClientID %>').prop('disabled', false).trigger("chosen:updated");