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

  • Home
  • SEARCH
  • 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 8235741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:54:52+00:00 2026-06-07T18:54:52+00:00

I currently have a set of divs (buttons) that all hover various colors using

  • 0

I currently have a set of divs (buttons) that all hover various colors using css. When one of this divs is pressed, I used jQuery to make the color permanent and reverted the color of all other divs back to default.

However, it seems that once this is done, the :hover color doesn’t work anymore. Am I approaching the jQuery wrong? How can I fix this. Here is an example:

EDIT

I am posting a jsfiddle to better explain. You will see that when you first scan your mouse across the divs, they hover different colors. And if you click either div 1 or div 2 (the others won’t work, didn’t bother doing the jQuery code for the fiddle for all of them), the div keeps it’s color and any other one reverts to original. HOWEVER, this then disables the :hover pseudo class I have in my CSS. I need help fixing this.

http://jsfiddle.net/P3Ckk/143/

What is the best solution to this?

  • 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-07T18:54:55+00:00Added an answer on June 7, 2026 at 6:54 pm

    Working Demo: http://jsfiddle.net/P3Ckk/145/

    I would rather do this way:

    HTML

    <div id='mainIconTile1' class="mainIconTile">
    </div>
    
    <div id='mainIconTile2' class="mainIconTile">
    </div>
    
    <div id='mainIconTile3' class="mainIconTile">
    </div>
    
    <div id='mainIconTile4' class="mainIconTile">
    </div>
    
    <div id='mainIconTile5' class="mainIconTile">
    </div>
    
    <div id='mainIconTile6' class="mainIconTile">
    </div>
    
    <div id='mainContentTile1'>
        1
    </div>
    
    <div id='mainContentTile2'>
        2
    </div>
    
    <div id='mainContentTile3'>
        3
    </div>
    
    <div id='mainContentTile4'>
        4
    </div>
    
    <div id='mainContentTile5'>
        5
    </div>
    
    <div id='mainContentTile6'>
        6
    </div>
    

    ​CSS

    .mainIconTile {
        background:#888888;                
        width:20px;
        height:20px;
        margin:1px;
        float:left;
    }
    
    #mainIconTile1:hover, #mainIconTile1.active {
        background:#5aa02c;
    }
    
    #mainIconTile2:hover, #mainIconTile2.active {
        background:red;
    }
    
    
    #mainIconTile3:hover, #mainIconTile3.active {
        background:blue;
    }
    
    
    #mainIconTile4:hover, #mainIconTile4.active {
        background:green;
    }
    
    #mainIconTile5:hover, #mainIconTile5.active {
        background:pink;
    }
    
    #mainIconTile6:hover, #mainIconTile5.active {
        background:brown;
    }
    
    #mainContentTile1 {
        background:orange;
        height:50px;
        width:50px;
        float:left;
        clear:left;
        display:none;
    }
    
    #mainContentTile2 {
        background:#e8e8e8;
        height:50px;
        width:50px;
        float:left;
        clear:left;
    
    }
    
    #mainContentTile3 {
        background:#e8e8e8;
        height:50px;
        width:50px;
        float:left;
        clear:left;
        display:none;
    }
    
    #mainContentTile4 {
        background:#e8e8e8;
        height:50px;
        width:50px;
        float:left;
        clear:left;
        display:none;
    }
    
    #mainContentTile5 {
        background:#e8e8e8;
        height:50px;
        width:50px;
        float:left;
        clear:left;
        display:none;
    }
    
    #mainContentTile6 {
        background:#e8e8e8;
        height:50px;
        width:50px;
        float:left;
        clear:left;
        display:none;
    }
    

    ​

    JavaScript

    $(document).ready(function(){
        $('div[id*="mainIconTile"]').click(function() {
            var theId = $(this).attr("id");
            $(".mainIconTile").removeClass('active');
            $("#" + theId).addClass('active');
            $('.mainContentTile:visible').hide(0, function(){
                $('#mainContentTile' + theId.substring(12)).show();
            });
        });
    });
    

    Working Demo: http://jsfiddle.net/P3Ckk/145/

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

Sidebar

Related Questions

Currently I have a site that is set up using a masterpage and a
Currently I have this: [SomeCustomAttribute] public string Name { get; set; } However, I
I have a four divs all set display:none and on document.ready i am showing
I currently have two side-by-side divs, each set to the width of the page
I am using content editable divs and I have overflow set to hidden. In
I have a set of divs that represent story categories. In each category, there's
In jQuery: Scenario ** - I have four Divs that have hover effects. -
I have a nav bar on my site that is currently one color and
Problem: I am currently creating a webpage layout using divs and css rather than
I have this jquery issue that seems to only break when using background image

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.