Detect whether radio button is disabled or enabled

This question already has an answer here:

  • How can I know which radio button is selected via jQuery? 29 answers

  • Use jQuery to attach to the click event of the radio button list and then use the jQuery :enabled selector, like this:

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

    Now you can remove the onclick attribute of your radio button list markup, because jQuery is going to find the radio button list ( rdStatus ) and wire up the click event to it for you.

    <asp:RadioButtonList ID="rdStatus" runat="server" RepeatDirection="Vertical">
    

    尝试这个:

    <asp:RadioButtonList ID="rdStatus"  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>
    
    $("#<%=rdStatus.ClientID%>").click(function(){
        if($(this).attr('enabled'))
        {
            $(this).removeattr('enabled');
            $(this).attr('disabled',true);
        }
        else
        {
        }
    });
    
    链接地址: http://www.djcxy.com/p/24576.html

    上一篇: 如何使用javescript在PHP中发送单选按钮值?

    下一篇: 检测单选按钮是禁用还是启用