Clear list of radio sharing with jquery

I want to clear the list of the Radiobutton list after the user types in the TextBox. I tried the following code, but it does not seem to work, and it does not show any errors. Please let me know if there are any suggestions.

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> 
+7
source share
4 answers

Instead:

 $('.checkboxlistid9').attr('checked',false); 

Try:

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

Also, I think your jQuery selector is wrong

 $('.checkboxlistid9') 

I do not see the checkboxlistid9 class on your asp:RadioButtonList

Change the query selector to:

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

or

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

The radio buttons are the descendants of the element that RadioButtonList represents, you can select them using #<%= rblLst.ClientID %> input[type=radio] and use .prop() to remove the checked property.

 function ClearRadioButtonList() { $("#<%= rblLst.ClientID %> input[type=radio]").prop('checked',false); } 
+2
source

You must use prop() . In addition, each() to retry:

 $('.checkboxlistid9').each(function (index, elem){ $(elem).prop('checked',false); }) 
+1
source
 $('.checkboxlistid9').removeAttr('checked'); 
0
source

All Articles