检测单选按钮是否已禁用或已启用

Blo*_*som 16 asp.net jquery radio-button isenabled

<asp:RadioButtonList ID="rdStatus" onclick="javacript:display();" runat="server" RepeatDirection="Vertical">
<asp:ListItem Text="Temporary Waiver" Value="T" Selected="True"></asp:ListItem>    
<asp:ListItem Text="Never Expires" Value="P"></asp:ListItem>    
<asp:ListItem Text="Expires after the close of:" Value="W"></asp:ListItem>
</asp:RadioButtonList>

function display()
{
    if(radiobuton is enabled)
          //code here
     else
          //code here
}
Run Code Online (Sandbox Code Playgroud)

请建议一些想法检测锄头检查radiobutton是禁用o启用

Kar*_*son 8

使用jQuery附加到单选按钮列表的click事件,然后使用jQuery :enabled选择器,如下所示:

$('#rdStatus').click(function () {
    if($(this).is(':enabled')) { 
        // Do enabled radio button code here 
    }
    else {
        // Do disabled radio button code here
    }
});
Run Code Online (Sandbox Code Playgroud)

现在您可以删除onclick单选按钮列表标记的属性,因为jQuery将找到单选按钮列表(rdStatus)并将click事件连接到它.

<asp:RadioButtonList ID="rdStatus" runat="server" RepeatDirection="Vertical">
Run Code Online (Sandbox Code Playgroud)