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?
$("input:radio[name='thename']").each(function(i) { this.checked = false; });
not sure why jquery support is not working and this is happening ...
As in jQuery 1.6, $("radio").prop("checked", false); - the proposed method.
$("radio").prop("checked", false);
Try using this: $('input[type="radio"]').prop('checked', false);
$('input[type="radio"]').prop('checked', false);
Using the jQuery prop method can change the properties of the elements (marked, selected, ect.).
The answer posted by @matzahboy worked great.
Tried other ways, but this worked best:
$(input[name=thename]).removeAttr('checked');
Try using the following code:
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.
To deselect all the radio stations in a group called "namegroup", try the following:
$("input[type=radio][name=namegroup]").prop("checked", false);
This is a simple and general answer (I believe): $("input[name=NAME_OF_YOUR_RADIO_GROUP]").prop("checked",false);
$("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
it worked for me;
$('input[name="radioName"]').attr('checked', false);