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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:20:25+00:00 2026-05-14T14:20:25+00:00

I am new to jQuery and need some help with the following problem. I

  • 0

I am new to jQuery and need some help with the following problem.

I have a simple table of data (20 rows by 4 columns) on a webpage (asp.net mvc). Note – I have built the table using <div> tags and not <table> <td> <tr> tags.

For each row there is summary data and then the option to click ‘Edit Record’ on the right hand side of the row. Clicking ‘Edit Record’ will make additional information visible.

Here is a pictorial: (nb in the ‘real’ table the names/dates are real names/dates etc.)

----------------------------------------------------------------------------
Name                 Date               Status               [ Edit Record]
----------------------------------------------------------------------------
Name                 Date               Status               [ Edit Record]
----------------------------------------------------------------------------

There are four effects I am trying to create:

  1. When a user hovers over a row the background color changes
  2. When a user clicks ‘Edit Record’ the additional information visibility is toggled
  3. When the additional information is visible the background-color changes.
  4. When the additional information is hidden the background-color defaults to white

So far I have the following jQuery code which almost works (see issue at bottom):

This code handles the ‘hover’ effect (1):

$("div.record").hover(function() {
      $(this).addClass("recordhover");
            }, function() {
                $(this).removeClass("recordhover");
});

This code handles the visibility of the additional information and background-color(2,3,4):

$("div.recordtopline > div.recorddetail").click(function(event) {
      if (this == event.target) {
          if ($(this).parent("div").next(".recordbelowline").is(':hidden')) {
              $(this).parent("div").next(".recordbelowline").show();
              $(this).parent("div").parent("div").animate({backgroundColor: "#FFEFC6" }, 'fast');
                }
                else {
                    $(this).parent("div").next(".recordbelowline").hide();
                    $(this).parent("div").parent("div").animate({ backgroundColor: "#FFF" }, 'fast');
                }
                return false;
            }
        });

Issue

When I load the webpage, the hover effect works perfectly for all rows. However, if I have selected ‘Edit Record’ to view more information and then made the additional information hidden the hover effect no longer works on that row i.e. the backgorund-color remains white as per my animation code.

How can I overcome this issue so that the hover effect ‘overrrides’ the background animation effect?

  • 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-14T14:20:25+00:00Added an answer on May 14, 2026 at 2:20 pm

    When you set styles directly on an element (with element.style.thing= or $(element).css() or, here, animate), you’re effectively adding an inline style="" attribute holding that rule. Inline style always overrides stylesheet rules.

    So after setting the background back to what it was, you would have to remove the rule:

    var record= $(this).parent('div').parent('div');
    record.animate(
        {backgroundColor: '#FFF'}, 
        {duration: 'fast', complete: function() {
            record.css('backgroundColor', '');
        }}
    );
    

    Are you using some plugin to make animating backgroundColor work? Normally it wouldn’t. If you don’t need the animation it’s much simpler to do, by just adding/removing a class on the row when it’s selected/unselected and letting the stylesheet handle it.

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

Sidebar

Related Questions

I'm new to jQuery and need some help to show and hide a div
I am very new to jquery and need some help. I am trying to
Ok, I am new to JQuery, I have a modal that has a asp:Literal
I have a script that appends some rows to a table. One of the
I'm pretty new to the jQuery world, so I'm hoping for some help. I
I need some help with a script I am developing. I have some advertisements.
I am new to MVC3.0 and have to use jquery. I as wondering some
I'm new to jquery and asp.net so please forgive if this is an obvious
I have a dynamic navigation and need to open one link in a new
i need some help with this, i'm trying to generate some html with javascript,

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.