Deselect a group of radio buttons using jQuery

I am using jQuery and I have a group of radio buttons with the same name but with different property values.

For example:

<input type = "radio" name = "thename" value="1"></input> <input type = "radio" name = "thename" value="2"></input> <input type = "radio" name = "thename" value="3"></input> 

I want to make sure that all of them are not selected. In the current state of my page, one of them clicked. How to do it?

+8
jquery radio-button
source share
9 answers
 $("input:radio[name='thename']").each(function(i) { this.checked = false; }); 

not sure why jquery support is not working and this is happening ...

+8
source share

As in jQuery 1.6, $("radio").prop("checked", false); - the proposed method.

+7
source share

Try using this: $('input[type="radio"]').prop('checked', false);

Using the jQuery prop method can change the properties of the elements (marked, selected, ect.).

+3
source share

The answer posted by @matzahboy worked great.

Tried other ways, but this worked best:

 $(input[name=thename]).removeAttr('checked'); 
+2
source share

Try using the following code:

 $(input[name=thename]).removeAttr('checked'); 
+1
source share
 function resetRadio(name) { $('#form input:radio[name=' + name + ']:checked').each(function () { var $this = $(this); $this.prop("checked", false); }); } $('#form input:radio').on('dblclick', function () { var $this = $(this); var name = $this.prop('name'); resetRadio(name); }); 

This allows you to double-click the radio stations until reset.

0
source share

To deselect all the radio stations in a group called "namegroup", try the following:

 $("input[type=radio][name=namegroup]").prop("checked", false); 
0
source share

This is a simple and general answer (I believe): $("input[name=NAME_OF_YOUR_RADIO_GROUP]").prop("checked",false);

For this specific question, I would use:

$("input[name=thename]").prop("checked",false);

Hope this helps

0
source share

it worked for me;

 $('input[name="radioName"]').attr('checked', false); 
0
source share

All Articles