2010-08-20 64 views
5

問候語。使用jquery啓用asp.net DropDownList控件

如何在檢查asp.net複選框時啓用或禁用使用jquery的asp.net DropDownList控件。

所以我有我有一個asp.net複選框,當我檢查它我想啓用/禁用DropDownList。

謝謝

回答

7

像這樣的事情可以做魔術

$('#<%= CheckBox1.ClientID %>').click(function(){ 
    if ($('#<%= DropDownList2.ClientID %>').prop('disabled') != true) 
    $('#<%= DropDownList2.ClientID %>').prop('disabled', true); 
    else 
    $('#<%= DropDownList2.ClientID %>').prop('disabled', false); 
}) 
1
$("#'<%=CheckBoxId.ClientID %>'").click(function(){ 
    if($("#'<%=CheckBoxId.ClientID %>'").attr('checked')) 
     $("#'<%=DropDownListID.ClientID %>'").attr('disabled', true); 
    else 
     $("#'<%=DropDownListID.ClientID %>'").attr('disabled', false); 
}); 
相關問題