Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

205
Vistas
Why does my stopwatch not get started when I click the start button?

This is the stopwatch I made but the start button is not working - it doesn't actually start the stopwatch.

I've tried to find solutions on the internet but I haven't been able to find anything.

var seconds = 00;
var tens = 00;
var appendTens = document.getElementsByClassName("tens");
var appendSeconds = document.getElementsByClassName("seconds");

var buttonStart = document.getElementById("btn-start");
var buttonStop = document.getElementById("btn-stop");
var buttonReset = document.getElementById("btn-reset");

var interval;

function startTimer() {
    tens++;
    
    if (tens < 9) {
        appendTens.innerHTML ="0" + tens;
    }
    if (tens > 9) {
        appendTens.innerHTML = tens;
    }
    if (tens > 99) {
        seconds++;
        appendSeconds.innerHTML = "0" + seconds;
        tens = 0;
        appendTens.innerHTML = "0" + 0;
    }
    if (seconds > 9) {
        appendSeconds.innerHTML = seconds;
    }
};

buttonStart.onclick = function() {
    interval = setInterval(startTimer);
}

buttonStop.onclick = function() {
    clearInterval(startTimer);
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="stopwatch.css">
    <title>StopWatch</title>
</head>
<body>

    <div class="container">
        <img src="/iconmonstr-clock-thin.svg" alt="">
        <h2>StopWatch</h2>
        <p><span class="seconds">00</span>: <span class="tens">00</span></p>
        
        <button class="btn" id="btn-start">Start</button>
        <button class="btn" id="btn-stop">Stop</button>
        <button class="btn" id="btn-reset">Reset</button>
   
   
        
    </div>
    
    <script src="stopwatch.js" type="application/javascript"></script>
</body>
</html>

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda