【问题标题】:jquery 1.9.1 disable radionbuttonlist listitemjquery 1.9.1 禁用radionbuttonlist listitem
【发布时间】:2013-11-27 00:11:23
【问题描述】:

我正在使用 asp.net。我想禁用 asp:radiobuttonlist 中的特定项目。我也在使用 jquery 1.9.1 并且已经阅读了我应该使用 prop 而不是 attr 。在这一点上我无法工作..希望有人能提供帮助。这是单选按钮列表

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

我已经尝试了几种不同的方法来做到这一点..它们都不起作用。如您所见,我正在尝试禁用原始条目列表项

            $("#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);

任何帮助都会很棒。 谢谢 香农

这是呈现的 html 的样子

<input id="ctl00_ContentPlaceHolder1_rblRegister_0" type="radio" name="ctl00$ContentPlaceHolder1$rblRegister" value="OE">

【问题讨论】:

    标签: jquery radiobuttonlist


    【解决方案1】:

    prop() 语法存在问题,因为它需要一个对象。

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

    JSFiddle

    【讨论】:

    • 感谢代码..禁用整个下拉列表..这是很好的代码。禁用单个列表项怎么样。我试过 $('input option[value='high']').prop({'disabled': true});从你的小提琴例子(顺便谢谢你),我的语法一定不正确
    • 我对 ASP 不熟悉,能把 ASP 生成的原始 HTML 贴出来吗?
    • 查看JSFiddle,了解如何缩小选择范围。
    猜你喜欢
    • 2011-09-15
    • 2023-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-18
    • 1970-01-01
    相关资源
    最近更新 更多