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