Uncheck radio button on click using jquery

DON picture DON · Aug 24, 2015 · Viewed 25.5k times · Source

Radio buttons are unchecked only at page refresh

<input type="radio" name="test">
    1<input type="radio" name="test">2
   <input type="button" id="btn" />

$("#btn").click(function(){

$(':radio').each(function () {
        $(this).removeAttr('checked');
        $('input[type="radio"]').attr('checked', false);
    })

}); 

I have created a fiddle http://jsfiddle.net/8jKJc/220/

But its not working with Bootstrap

Answer

Mohit Kumar picture Mohit Kumar · Aug 24, 2015

Use .prop instead of .attr:

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

[Demo]