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

306
Visualizações
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
  }
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

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();
  }
}
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