Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7714987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:16:26+00:00 2026-06-01T02:16:26+00:00

I have a following HTML <div id=btn_1>Button 1</div> <div id=btn_2>Button 1</div> <div id=btn_3>Button 1</div>

  • 0

I have a following HTML

<div id="btn_1">Button 1</div>
<div id="btn_2">Button 1</div>
<div id="btn_3">Button 1</div>

I want add a css class for period of time, for example: If the hour is between 00:00 to 06:59 add class “select” to id “btn_1”, for between 07:00 to 10:59 am add the class to id “btn_2”, and finally 11:00 to 16:00 add class to id “btn_3”.

Any help please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T02:16:27+00:00Added an answer on June 1, 2026 at 2:16 am
    $(function() {
        // get hour of time
        var hour = (new Date).getHours();
    
        // remove select class if already applied
        $('.select').removeClass('select');
    
        if (hour < 7) {  // 0:00 to 6:59
            $('#btn_1').addClass('select');
        } else if (hour < 11) {  // 7:00 to 10:59
            $('#btn_2').addClass('select');
        } else if (hour < 16) {  // 11:00 to 15:59
            $('#btn_3').addClass('select');
        }
    
    })
    

    Demo: http://jsfiddle.net/fS3jj/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following html <div id=menu> <ul class=horizMenu> <li id=active><a href=# id=current>About</a></li> <li><a
I have the following HTML <div id=testID class=test1> <img id=testID2 class=test2 alt= src=some-image.gif />
onI have the following html structure: <div> <ul> <li class=gravity-form></li> <li class=gravity-form-divider></li> </ul> </div>
i have following HTML structure: <div class=container> <div class=sidebar></div> <div class=content></div> <div class=subscript></div> </div>
I have following html: <div class=rows> <div class=row><input type=text onchange=javascript:getIndex(this); value= /></div> <div class=row><input
I have the following HTML: <div class=right-bar> <span class=>£100</span> </div> <div class=middle> <span class=>£200</span>
I have the following html code: <div class= modal id=indexModal> <span class=thing></span> <a href=#
I have the following html and css <div id=header> <div id=headerTopLeft> <div id=areaSelect style=display:
I have the following CSS and HTML: div#actionList { float: left; height: 25px; margin:
I have following html snippet: <div class=rsw-pp rsw-pp-widget> <div g:type=AverageStarRating g:secondaryurls=http://maps.google.com/?cid=12948004443906002997 g:decorateusingsecondary=http://maps.google.com/?cid=12948004443906002997 g:groups=maps g:rating_override=2.998000

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.