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

174
Visualizações
window.setInterval to start only when I click the start game button and need to get that without using functions

I want the window.setInterval to start only when I click the start game button and need to get that without calling a function for SetInterval.Right now the setInterval works as soon as the page is loaded and generates random letters.

I have tried the following code:

(The start game button)

<td style="text-align: center;" colspan="3"><button id="rndletter">Start game</button>

<script>
    document.getElementById("rndletter").addEventListener("click", window.setInterval(function() {

                var result0 = String.fromCharCode(Math.floor(Math.random() * (122 - 97)) + 97);
                

                var result1 = String.fromCharCode(Math.floor(Math.random() * (122 - 97)) + 97);
                

                var result2 = String.fromCharCode(Math.floor(Math.random() * (122 - 97)) + 97);
                

                document.getElementById("result0").innerText = result0;
                document.getElementById("result1").innerText = result1;
                document.getElementById("result2").innerText = result2;
            },2000));
</script>
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