Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

147
Visualizações
Uncaught TypeError: Cannot set properties of null (setting 'onclick')

Right now i am having this issue that i just can't seem to fix and the only better place than to look for how to fix this is stack overflow so here is the code HTML:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="description" content="Hallo this is a game" />
<link rel="icon" href="images/SpongeBob_SquarePants_character.svg.png" />
<script src="index.js"></script>
<title>Javascript Game</title>
</head>

<body>
<script src="index.js"></script>
<label for="averynicebutton">Button</label>
<input type="checkbox" id="averynicebutton" /> <br />
<button id="submitButton">Submit</button>
</body>
</html>

again very simple code heres the javascript:

document.getElementById("averynicebutton").onclick = function(){
  
if(document.getElementById("averynicebutton").checked){
    console.log("you clicked a button Woo-Hoo!")
  }
}

Also heres a image for reference

so if you know how this problem occurred please tell me as i am very puzzled on how this happened as i am very new to javascript. Thank you for taking the time to read this. Bye Bye

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda