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

前端之家收集整理的这篇文章主要介绍了javascript – 使用jquery清除radiobutton列表选择前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想在用户在TextBox中输入文本后清除Radiobutton列表选择.我尝试了以下代码,但它似乎没有工作,它没有显示任何错误.如果有任何建议,请告诉我.
  1. function ClearRadioButtonList() {
  2. var checkBoxlistid9 = "#<%= rblLst.ClientID %>";
  3. $('.checkBoxlistid9').attr('checked',false);
  4. }
  5.  
  6. <telerik:RadMaskedTextBox ID="txtCode" runat="server" Mask="###-##-####" SelectionOnFocus="CaretToBeginning">
  7. <ClientEvents OnBlur="ClearRadioButtonList" />
  8. </telerik:RadMaskedTextBox>
  9.  
  10. <asp:RadioButtonList ID="rblLst" runat="server" RepeatDirection="Horizontal">
  11. <asp:ListItem Value="1">Unknown</asp:ListItem>
  12. <asp:ListItem Value="2">Not Applicable</asp:ListItem>
  13. </asp:RadioButtonList>

解决方法

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

尝试:

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

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

  1. $('.checkBoxlistid9')

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

查询选择器更改为:

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

要么

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

猜你在找的jQuery相关文章