This question has already been answered:

In theory, this code should work, but it was not there ...

<input type="radio" value="1"> <input type="button" value="strat" id="btn"> 

Javascript code

 btn.onclick = function(){ var delet = document.querySelectorAll('input[type="radio"]'); for(var i = 0; i < delet.length; i++){ delet.checked = false; } if(delet.checked = false){ alert("true"); } else { alert("false"); } } 

Reported as a duplicate at Grundy. javascript Dec 29 '16 at 20:00 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

    1 answer 1

    You must refer to the delet list delet within the loop, not the delet list delet .

     btn.onclick = function(){ var delet = document.querySelectorAll('input[type="radio"]'); for(var i = 0; i < delet.length; i++){ delet[i].checked = false; } }