• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

183
Vistas
How to change the time of a pomodoro timer when I change the button tab?

I'm learning javascript and I'm having a very hard time to learn the logic behind. I'm trying to make a pomodoro timer but I can't figure out how to change the time when I change the button tab to "break". I've been trying to do this for about 5/6 days now and I'm running out of ideas and my logic just don't work.

In my last attempt I created a function to see if the break button element had an "active" class and change the time if it did but it didn't work.

function changeTimeBreak() {
  const breakTab = document.getElementsByClassName('break-tab')
  
   if (breakTab.hasClass('active')) {
     minutes = 10
     updateCounterEl()
     return
  }
}
almost 3 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You are using JQuery's .hasClass method. What you should use is Javascript's element.classList .contains method.

I've edited your function. This should update the clock when break-tab button is active.

function changeTimeBreak() {
  let breakTab = document.getElementsByClassName('break-tab');
  
   if (breakTab[0].classList.contains('active')) {
     minutes = 10;
     updateCounterEl();
  }
}
almost 3 years ago · Juan Pablo Isaza Denunciar
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 Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda