Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

152
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!