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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:42:57+00:00 2026-05-30T08:42:57+00:00

In my program I have 3 divisions with class ‘information’, ‘interest’ and ‘wall’. I

  • 0

In my program I have 3 divisions with class ‘information’, ‘interest’ and ‘wall’.
I want this divisions to change their color when a a user clicks on it.
Initially all 3 division classes have same color #dcdcdc.
When user clicks on 1 of them I want to change its color to #999, but color of other divisions must remain #dcdcdc.

This much part is working correctly but when i click on 2nd division, the previous doesn’t change its color back to #dcdcdc.

JavaScript part.

$(document).ready(function(){
 $('#pro_head > div').click
 (
  function() 
  {
   $(this).css("background-color", "#999");
   $(this).css("font-weight", "bold");
  },
 );
});

HTML part:

<div pro_head>
  <div class="information"></div>
  <div class="interest"></div>
  <div class="wall"></div>
</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-05-30T08:42:58+00:00Added an answer on May 30, 2026 at 8:42 am

    CSS

    .selected {
       background-color: #999;
       font-weight : bold;
    }
    

    JS

    $(document).ready(function(){ 
      var divs1 = $('#pro_head1 > div'), /* I'm guessing selectors */
          divs2 = $('#pro_head2 > div'), 
          addHandler = function(divs) {
             divs.on('click', function() { 
                divs.removeClass('selected');
                $(this).addClass('selected');
             }); 
          };
    
     addHandler(divs1);
     addHandler(divs2);
    
    })
    

    The idea is to create a special class that has to be applied on the selected division (and removed elsewhere). In this way you could manage complex style without specifying all css rules inside JS and you can better identify presentational layer from functional layer

    Edit: updated after user request in a comment.

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

Sidebar

Related Questions

I have program that has a variable that should never change. However, somehow, it
I have program that runs fast enough. I want to see the number of
in a C program I have an long* that I want to serialize (thus
with my RCP program I have the problem that I want to have more
I have a DLL written in C#. In this DLL there is a class
I'm trying to profile a program with this class: namespace smtx{ class CPerformance_clock {
Have you ever thought about the implications of this change in the Java Programming
I have manualy writing class for WinSock. My program have more that one threads.
I have program, that must interact with a console program before my program can
Most program languages have some kind of exception handling; some languages have return codes,

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.