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

153
Visualizações
eventlistener and window.onload not working for me

I've tried several things to make it work. It worked before when I hosted it all on the same file, but now it won't work when I separated it on my script.js.

this is part of my code

var buttonStart = document.getElementById("forward");
var buttonStop = document.getElementById("stop");

buttonStart.addEventListener("click", speedup);

function speedup() {
  clearInterval(Interval);

  speed = speed + 1;

  Interval = setInterval(valuecalc, 1000 / speed);
  document.getElementById("speed").innerHTML = speed;
};

buttonStop.addEventListener("click", stopspeed);

function stopspeed() {
  clearInterval(Interval);
  speed = 0;
  document.getElementById("speed").innerHTML = speed;
};

var starts = start();
window.onload = starts;

Here's the live demo it's a sort of clicker game I'm working on: https://jobclicker.netlify.app/

This is my error: script.js:35

Uncaught TypeError: Cannot read properties of null (reading 'addEventListener') at script.js:35:17

about 4 years ago · Santiago Gelvez
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