You may be using also this way below
Renan’s code.
<button id='block'>Bloquear Formulário</button>
<p><strong>1) Quantas patas tem um cachorro?</strong></p>
<form>
<input type='radio' name='dog'/>1<br>
<input type='radio' name='dog'/>2<br>
<input type='radio' name='dog'/>3<br>
<input type='radio' name='dog'/>5<br>
<input type='radio' name='dog'/>Tenho certeza que não são 4<br>
</form>
Only the Javascript code will change, I think it is better to do this way
var radios = document.getElementsByName('dog');
document.getElementById('block').onclick = function(){
radios.forEach(function(el) {
el.checked = false;
el.disabled = true;
});
}
Better (in performance) is not, but it’s an alternative.
– Renan Gomes