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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:55:52+00:00 2026-06-04T12:55:52+00:00

Take a look at: http://jsfiddle.net/PPsHd/ As expected, hovering over the center div triggers the

  • 0

Take a look at:

http://jsfiddle.net/PPsHd/

As expected, hovering over the center div triggers the hover events for all the divs. Is there a way to change the background of only the first div under the hovering mouse? That is, hovering over the center div changes only the center div’s color?

edit: This needs to be possible for an arbitrary number of nested divs added by the user and I would be able to do it in javascript, but would prefer a CSS solution.

I’m already using:

(function(){
    var highlightedDiv;
    $(document.body).on('mouseover','div',function(e){
        if(highlightedDiv){
            highlightedDiv.style.backgroundColor='';
        }
        (highlightedDiv=this).style.backgroundColor = 'lightGray';
        e.stopPropagation();
    });
}
)()

​

​

  • 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-04T12:55:54+00:00Added an answer on June 4, 2026 at 12:55 pm

    You’re falling foul of event bubbling – I can’t see how you’ll be able to do it just in CSS –

    If you’re happy to use a bit of jQuery – you can do it:

    $("DIV").bind("hover",function(event){
        $(".Hover").removeClass("Hover");
        $(this).addClass("Hover");     
        event.stopPropagation();
     });
    

    CSS:

    div{
        padding-top:50px;
        margin:auto;
        border:1px solid lightGray;
        background:gray;
    }
    .Hover{
        background:lightGray;
    }
    

    The trick is to stop the event bubbling up to the other divs – you can see it in action.

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

Sidebar

Related Questions

Hi, Pleas take look at this example : http://jsfiddle.net/snowman/Hne3h/1/ If you hover over the
Please take a look at the following example: http://jsfiddle.net/MVfVD/ I want the overlayedFrameFooter div
Please take a look at this: http://jsfiddle.net/UQNJA/1/ It looks fine in all modern browsers
Take a look at the following: http://jsfiddle.net/Jakobud/VfVnN/7/ I want the .title div to be
Take a look at the following jsfiddle: http://jsfiddle.net/tTNNm/ How do you get the div.text
take a look at the JsFiddle here: http://jsfiddle.net/ru2Fg/2/ Essentially, it starts with two textarea
If you take a look at the following JS: (Live: http://jsfiddle.net/RyanWalters/dE6T3/2/ ) var projects
Could someone possibly take a look at this: http://jsfiddle.net/VkFRU/4/ and explain the console output
Well Im stucked at this point.please take a look at this http://jsfiddle.net/karthik64/5jhgF/3/ Okay first
Take a look at my fiddle: http://jsfiddle.net/jVsQY/ As you can see, I'm using text-align:

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.