How to clear radio button in Javascript?

You don't need to have unique id for the elements, you can access them by their name attribute:

If you're using name="Choose", then:

  • With jQuery it is as simple as:

    $('input[name=Choose]').attr('checked',false);
    
  • or in pure JavaScript:

       var ele = document.getElementsByName("Choose");
       for(var i=0;i<ele.length;i++)
          ele[i].checked = false;
    

    Demo for JavaScript


If you do not intend to use jQuery, you can use simple javascript like this

document.querySelector('input[name="Choose"]:checked').checked = false;

Only benefit with this is you don't have to use loops for two radio buttons


This should work. Make sure each button has a unique ID. (Replace Choose_Yes and Choose_No with the IDs of your two radio buttons)

document.getElementById("Choose_Yes").checked = false;
document.getElementById("Choose_No").checked = false;

An example of how the radio buttons should be named:

<input type="radio" name="Choose" id="Choose_Yes" value="1" /> Yes
<input type="radio" name="Choose" id="Choose_No" value="2" /> No