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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:06:47+00:00 2026-06-10T05:06:47+00:00

this is a first question on stack overflow, so please be patient. I have

  • 0

this is a first question on stack overflow, so please be patient.

I have a listing of appointments set out in rows with alternating background colors for readability determined by the class grey.

    <div class="grid_13 alpha omega entry grey">
    <div class="grid_3 alpha start">Sat 05/05/2012 10:00 am</div>
    <div class="grid_3">Sat 05/05/2012 10:15 am</div>
    <div class="grid_3">ME</div>
    <div class="grid_3 omega">Attended</div>
</div>
<div class="grid_13 alpha omega entry">
    <div class="grid_3 alpha start">Tue 01/05/2012 9:00 am</div>
    <div class="grid_3">Tue 01/05/2012 10:00 am</div>
    <div class="grid_3">MDH</div>
    <div class="grid_3 omega">Scheduled</div>
</div>
<div class="grid_13 alpha omega entry grey">
    <div class="grid_3 alpha start">Mon 30/04/2012 8:45 am</div>
    <div class="grid_3">Mon 30/04/2012 9:45 am</div>
    <div class="grid_3">ME</div>
    <div class="grid_3 omega">Scheduled</div>
</div>
<div class="grid_13 alpha omega entry">
    <div class="grid_3 alpha start">Thu 26/04/2012 11:00 am</div>
    <div class="grid_3">Thu 26/04/2012 12:00 pm</div>
    <div class="grid_3">ME</div>
    <div class="grid_3 omega">Scheduled</div>
</div>

On mouseover I am trying to remove the class grey, which I am able to do, and then add another background color as a highlight, then remove it on mouseout which I can also manage.

        $(".entry").mouseover(function(){
        $(this).removeClass("grey");
        $(this).addClass("highlight");
    });
    $(".entry").mouseout(function(){
        $(this).removeClass("highlight");
    });

However I can’t work out how to reinstate the class grey, but only if it had the class grey in the first place. I have tried

    if ($(".entry").attr('class') == "grey") {
            $(this).hover(
            function(){ $(this).removeClass("grey"); $(this).addClass("highlight"); },
            function(){ $(this).removeClass("highlight"); $(this).addClass("grey"); }
        )
    } else{
        $(this).hover(
            function(){ $(this).addClass("highlight"); },
            function(){ $(this).removeClass("highlight"); } 
        )
    };

plus some other combinations, none of which seem to work.

  • 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-10T05:06:49+00:00Added an answer on June 10, 2026 at 5:06 am

    Like I said in my comment, add a class called for example canhavegray on every element that has the class gray. Then this function should work:

    $('.entry').mouseover(function(){
        $(this).removeClass('grey'); // Will only happen if the element has the class gray
        $(this).addClass('highlight');
    })
    $('.entry').mouseout(function(){
        if ($(this).hasClass('canhavegray')) // If the element has this class, it will readd it here
            $(this).addClass('grey');
        $(this).removeClass('highlight');
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is my first question on stack overflow. Some quick background, this is not
I'm an XML Schema noob, and this is my first Stack Overflow question. Please
This is my first question in stack overflow. Please be liberal in validating it
This is my first question on Stack Overflow, so I hope that I'm clear
( Preface: This is my first audio-related question on Stack Overflow, so I'll try
First off - hello, this is my first Stack Overflow question so I'll try
This is my first question here on stack overflow. i need help on a
This is my first post to Stack Overflow so please forgive me if I
Hello all this is my first question on stack overflow. I am developing an
This is my first question on Stack Overflow. Apologies in advance if I don't

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.