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

163
Visualizações
Input text stacking

I'm making a clicker game in which you press spacebar to increase the counter. Every time the counter goes up the next value is "stacked" on top of it, making it overlap. So if the counter was 1 and the spacebar is pressed, then the next value,(2) would overlap the 1. How do I fix this? (Please bear in mind that I'm not very well versed in coding yet, so please try to keep it as dumb as possible)

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can try something like the following:

var count = 0;
document.addEventListener("keypress", function(e) {
    if (e.code === "Space") {
        count++;
        document.getElementById("counter").innerHTML = count;
    }
});
<div>Count: <span id="counter">0</span></div>

This will replace the previous value with the new counter value everytime the space bar is pressed

about 4 years ago · Juan Pablo Isaza Relatório
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