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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:37:44+00:00 2026-05-23T03:37:44+00:00

This question may have been asked before and I’m sorry if I missed it,

  • 0

This question may have been asked before and I’m sorry if I missed it,

I have this drop down menu structure :

<ul id="menu">
    <li><a>text1</a></li>
    <li class="withchild"><a class="itemchild">text2</a>
        <ul>
        ...
        </ul>
    </li>
    <li><a>text3</a></li>
</ul>

I’m changing itemchild‘s background on hover.

$("li.withchild ul").hover(function(){
    $(this).parent().find('.itemchild').css('background','the new background');
},
function(){
    $(this).parent().find('.itemchild').css('background','the old background');
});

And a the CSS for li.withchild a.itemchild:hover{the new background}

My problem : If I hover over .itemchild the background changes, and then hover over

li.withchild ul , .itemchild‘s background remains with new background. But if I hover off

li.withchild ul back onto .itemchild the background returns to old background.

What is the best way to work around 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-05-23T03:37:45+00:00Added an answer on May 23, 2026 at 3:37 am

    If you want to have .itemchild display the new background when your mouse is over EITHER .itemchild OR li.withchild ul, the best way would probably be to attach the hover to the parent element:

    $("li.withchild").hover(function(){
        $(this).find('.itemchild').css('background','the new background');
    },
    function(){
        $(this).find('.itemchild').css('background','the old background');
    });
    

    Or, you could first wrap li.withchild ul and .itemchild into a new div of their own with wrapAll() and then attach the event to that.

    Am I understanding your question correctly?

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

Sidebar

Related Questions

This question may have been asked before, but I had trouble finding an answer,
This question may have been asked before, but I'm starting to get into game
I'm aware that this question may have been asked before, but I still haven't
First, this question may have been asked before, but I'm not sure what phrase
This question may well have been asked before but I didn't find anything whilst
This question may have been asked before, but I couldn't find an answer to
This question may have been asked already - but unfortunately, I could not find
I realize that this question may have been asked several times in the past,
this question may have been asked many times, but could not find any suitable
This question has been asked before, but I can't find any answers that have

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.