Twitter Facebook Google+ LinkedIn Pinterest Tumblr Reddit
Question

make all radio button unchecked

Tags: html jquery
Date:
Status:Resolved
Question Id:23

I have clear button. I want to make all radio buttons unselect when I click the button. How can I solve this with jquery ?

<div class="col-md-2">
    <div class="form-check-inline">
       <label class="form-check-label">
            <input type="radio" class="form-check-input" name="s<%=bas3[i].id %>" value="Evet">Evet
       </label>
    </div>
    <div class="form-check-inline">
       <label class="form-check-label">

            <input type="radio" class="form-check-input" name="s<%=bas3[i].id %>" value="Hayır">Hayır
       </label>
    </div>
 </div>
 <button id="clearBtn" type="button" class="btn btn-info btn-sm">Clear</button>
 
Answer
Date:
Correct:No

ou can give them a classname and try:

$('.classname').prop('checked', false);

When you use an older version of jQuery than 1.6 it has to be:

 $('<selector>').attr('checked', false);

Call the method .checkboxradio("refresh"); has also worked for me.

Answer
Date:
Correct:No

$('input:radio[name=indicatorType]').each(function () { $(this).prop('checked', false); });

Alternative solution for making 'unchecked' whole radio buttons of a radio group('indicatorType' for above code sample).

Answer
Date:
Correct:No

This should do it. Notice the refresh option at the end to force the controlgroup to be updated.

An additional benefit of this method is that it targets a specific radio group by name, rather than all radio controls on a page.

$('input:radio[name=emptim]:checked').prop('checked', false).checkboxradio("refresh");

Answer
Date:
Correct:No

The prop doesnt works for me, bu this works perfectly :

$('input:radio[name="RadioName"]').each(function () { $(this).attr('checked', false); });
Answer
Date:
Correct:No

If you want to uncheck all the radio buttons you will need to add one single line

$('#clearBtn').click(function () {
               $('input[type="radio"]').prop('checked'false);
});

According to jQuery website the .prop is gets the value of a property for the first element in the set of matched elements or set one or more properties for every matched element. In another words it will look for the "checked" property and, if you want, it can change its value as well.

Easy, simple and clean.

Answer
Date:
Correct:No

guys thank you for answers. But I dont want to use class, id or [name=] . I found the solution I want : 

$"#clearBtn" ) .click(function () {    
    $("input").prop('checked'false);
});

Your Answer

Review Your Answer