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 8809283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:50:06+00:00 2026-06-14T02:50:06+00:00

I have a dynamically generated div named time_holder which has a number of occurences

  • 0

I have a dynamically generated div named time_holder which has a number of occurences depending on the amount of rows returned from a database.

When one of the divs is clicked I want the background to change colour and all the other time_holder divs to remain or change back to the original colour. I though a simple reset would have done the job but this does not seem to work :

$(document).on('click', '.time_holder', function(){
$('.time_holder').css('background-color', '#EODEF3');
$(this).css('background-color', '#ccc');
});

I was expecting the first line to reset all the timeholder divs to the original colour and then the second line to change the background of the clicked div.

  • 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-14T02:50:07+00:00Added an answer on June 14, 2026 at 2:50 am

    addClass isn’t for adding attributes. Use .css(). Here’s the code, simplifying a bit event binding:

    $('.time_holder').on('click', function() {
        $('.time_holder').css('background-color', 'red');
        $(this).css('background-color', 'blue');
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a scrollable div element with a number of checkboxes dynamically generated. I
The table will get generated dynamically from the server-side code, which I have to
I have a page in which one chooses from a selection of dynamically generated
Fiddle: http://jsfiddle.net/MhWm5/16/ I have some dynamically generated table rows/values with dynamic IDs <td class=control-group>
Background: I'm trying to produce dynamically generated Factsheets, where each Factsheet has a number
I have a dynamically generated array from a database. Basically it's an array of
I have the following table dynamically generated from a view. I need to add
I have a jsp webpage which is dynamically generated. I want to have tooltips
I have dynamically generated code like the following: <div class=message-error error>The Message field is
I am trying to create a CSV file from a dynamically generated table.I have

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.