微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

javascript – 使用jquery清除radiobutton列表选择

我想在用户在TextBox中输入文本后清除Radiobutton列表选择.我尝试了以下代码,但它似乎没有工作,它没有显示任何错误.如果有任何建议,请告诉我.
function ClearRadioButtonList() {
    var checkBoxlistid9 = "#<%= rblLst.ClientID %>";
    $('.checkBoxlistid9').attr('checked',false);     
}

<telerik:RadMaskedTextBox ID="txtCode" runat="server" Mask="###-##-####" SelectionOnFocus="CaretToBeginning">
    <ClientEvents  OnBlur="ClearRadioButtonList" />
</telerik:RadMaskedTextBox>

<asp:RadioButtonList ID="rblLst" runat="server" RepeatDirection="Horizontal">
    <asp:ListItem Value="1">UnkNown</asp:ListItem>
    <asp:ListItem Value="2">Not Applicable</asp:ListItem>
</asp:RadioButtonList>

解决方法

代替:
$('.checkBoxlistid9').attr('checked',false);

尝试:

$('.checkBoxlistid9').removeAttr('checked');

另外我认为你的jQuery选择器是错误

$('.checkBoxlistid9')

我没有在你的asp:RadioButtonList上看到一个类checkBoxlistid9

查询选择器更改为:

$("table[id$=rblLst] input:radio:checked").removeAttr("checked");

要么

$("table[id$=rblLst] input:radio").each(function (i,x){
    if($(x).is(":checked")){
        $(x).removeAttr("checked");
    }
});

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐