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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:23:39+00:00 2026-06-09T00:23:39+00:00

I have several divs with the class .note and the following css code for

  • 0

I have several divs with the class .note and the following css code for them:

    .note{
            background: #eff9ff;
            -webkit-transition: background .5s;
        }

            .note:hover{
                background: #d6e4f2;
            }

            .note:active{
                background: #bfcdda;
            } 

Due to the webkit animation, it will change colors smoothly after hovering over the div.

However, I also use jQuery to change the background of the div completely depending on the attribute ‘selectednote’ once it is clicked, and only undo that once it is clicked again, like so:

$('.note').click(function(){
if($(this).attr('selectednote')=='no'){
    $(this).attr('selectednote','yes');
    $(this).css('background','#bfcdda');
}else if($(this).attr('selectednote')=='yes'){
    $(this).attr('selectednote','no');
    $(this).css('background','#eff9ff');
}
});

Everything works fine, but as soon as I click the div and it has changed its background, the css hover and active effects don’t work anymore.

Maybe I should get rid of css for that completely? I have tried to come up with the following jQuery for the hovering effect, but to no avail:

$('.note').mouseover(function(){
$(this).animate({
    background: '#d6e4f2'
},500);
});

What am I doing wrong here?

  • 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-09T00:23:41+00:00Added an answer on June 9, 2026 at 12:23 am

    You can stick using CSS for this without using invalid custom attributes like that one.

    .note.selected {
      background: #bfcdda;
    }​
    

    A simple toggle of the class selected. You can tweak this using .data() also.

    $('.note').click(function(){
      $(this).toggleClass("selected");
    });​
    

    See it working.

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

Sidebar

Related Questions

Suppose I have this class: .MyClass{background:red;} This class applies to several divs. I want
I have several divs that I want to generate css background images for. They
I have several divs with class image and several with class thumbnail (both can
I have several divs that share a common class. If one of these divs
I have a DIV container with several inner DIVs layed out by floating them
Not sure why this isn't working... I have several DIVs with an class of
I have several hidden divs on a page , some of them having the
I have several divs with the same ID's (#viewport_outer) , on hover I'm trying
I have several divs for displaying demo boxes of graphics, and code boxes for
I have several fixed position divs with the same class at varying distances from

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.