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

95
Visualizações
Set up time to change class
<div class="col-12 first-div">
</div>

<div class="col-12 second-div">
</div>

How do I set up to change the class on a FIRST DIV at a specific time, with jQuery or javascript .

I want the FIRST DIV to be visible until a certain date and time, then for it to become a DISPLAY:NONE and for the SECOND DIV to become visible at that time, and to restart the page once.

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

0

I think you can use a setInterval() to check the time every second , and if the time is between your specified times , show and hide the divs



function refreshTime() {
    const now = new Date().getHours()
    if (now >= 9 && now <= 18) { //show the first div from 9 am to 6 pm
        document.getElementById('first-div').style.display ='block';
        document.getElementById('second-div').style.display ='none';  // to display
} else {
       document.getElementById('second- div').style.display ='block';
        document.getElementById('first-div').style.display ='none';  // to display
 }
}
 setInterval(refreshTime, 1000);

replace the 1000 inside the setInterval to anyother number if you dont want to recheck the time every one second ,

about 4 years ago · Juan Pablo Isaza Relatório

0

I fail to refresh the page with this only once.I fail to refresh the page with this only once.

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