Pregunta

I'm using asp.net. I'd like to disable a specific item in a asp:radiobuttonlist. I'm also using jquery 1.9.1 and have read that instead of the attr I should be using prop. I can't get either to work at this point.. was hoping someone could help. Here is the radiobuttonlist

<asp:RadioButtonList ID="rblRegister" runat="server">
        <asp:ListItem Text="Original Entry" Value="OE" />
        <asp:ListItem Text="Promotional" Value="P" />
    </asp:RadioButtonList>

I've tried several different ways of doing this.. none of them are working. As you can see, i'm trying to get the Origninal Entry list item to be disabled

            $("#ctl00_ContentPlaceHolder1_rblRegister_0 option[value='OE']").prop("disabled", true);
        $("[id$=rblRegister option[value='OE']]").attr("disabled", "disabled");
        $("[id$=rblRegister option[value='OE']]").prop("disabled", true);

any help would be great. thanks Shannon

Here is what the rendered html looks like

<input id="ctl00_ContentPlaceHolder1_rblRegister_0" type="radio" name="ctl00$ContentPlaceHolder1$rblRegister" value="OE">
¿Fue útil?

Solución

There is an issue with the prop() syntax because it is expecting an object.

$('input').prop({'disabled':true})

JSFiddle

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top