dimanche 2 août 2020

JS - Checkbox doesn't work when I click on it

When I check the checkbox, nothing happens. Can you help me where the problem is?

<input type="number" min="1900" max="2099" step="1" value="2016" id="dateInput"><br>
<input type="checkbox" name="" id="firstcheck" onchange="setDate()">Present
  function setDate() {

    let check = document.querySelector("#firstcheck");
    let element = document.querySelector("#dateInput");
    

    if (check.chcecked == true) {
      element.value = new Date().getFullYear();

    }
    else if (check.chcecked == false) {
      element.value = 2006;
    }
  }



Aucun commentaire:

Enregistrer un commentaire