Select and de-select radio inputs with js

0

Well, colleagues, I have this, but it does not send me a mistake to console, although I can not select, can someone tell me what I'm doing wrong?

< script >
  let ord = document.querySelector("#ord");
let comp = document.querySelector("#comp");

if (ord.checked = true) {
  comp.checked = false;
} else if (comp.checked) {
  ord.checked = false;
}

<
/script>
<input id="ord" type="radio" name="Ordinario" value="0"> Ordinario<br>
<input id="comp" type="radio" name="Complemento" value="1"> Complemento
    
asked by E.Rawrdríguez.Ophanim 28.09.2018 в 21:35
source

1 answer

0

Ready only changed the name of both by the same name

<input id="ord" type="radio" name="tipo" value="0"> Ordinario<br>
<input id="comp" type="radio" name="tipo" value="1"> Complementontroducir el código aquí
    
answered by 28.09.2018 в 21:39