Clear button radio button

3

Good morning I would like to know how do I clear what was clicked on the radiobutton button, because in the textBox I use the name.Clear (); I would like to know how I can do it on the radio button

Thank you.

    
asked by anonymous 16.11.2016 / 14:24

2 answers

1

Simply change the element attribute from checked to false .

In jQuery, you can select by id or name , for example:

$('input[name=Choose]').attr('checked',false);

In pure Javascript:

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

Retired from StackOverflow in English in response to NVRAM

    
16.11.2016 / 14:31
1

To uncheck a specific input just make elemento.checked = false; .

In case you have several, you have to iterate and do one by one. Something like:

var inputs = document.querySelectorAll('input[type="radio"]');
for (var i = 0, l = inputs.length; i < l; i++){
    inputs[i].checked = false;
}

But often what you want is to re-start a form, this can be done with:

document.querySelector('form').reset();
    
16.11.2016 / 17:53