Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

90
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!