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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:18:25+00:00 2026-06-09T06:18:25+00:00

Im trying to setup so that when you hover over class .object1 -> in

  • 0

Im trying to setup so that when you hover over class .object1 -> in turn should reveal .obj_1 when you are not hovered on it, it should hide .obj_1. I may be a little off in my code, thanks for the help!.

$(document).ready(function() {   
  $(".obj_1 , .obj_2").hide();
      });
      $(".object1").hover(
        function() { $(".obj_1").show(); },
        function() { $(".obj_2").hide(); }
   );
      $(".object2").hover(
        function() { $(".obj_2").show(); },
        function() { $(".obj_1").hide(); }
   );
  • 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-09T06:18:28+00:00Added an answer on June 9, 2026 at 6:18 am

    Very simple it should be

    $(document).ready(function() {   
      $(".obj_1 , .obj_2").hide();
          });
          $(".object1").hover(
            function() { $(".obj_1").show(); },
            function() { $(".obj_1").hide(); }
       );
          $(".object2").hover(
            function() { $(".obj_2").show(); },
            function() { $(".obj_2").hide(); }
       );
    

    The “hover” handler function signature is ( mouseInHandler, mouseOutHandler).
    For object1 you want to show obj_1 on mouseIn, and hide it on mouseOut.
    You don’t need to reference obj_2 on object1 hover handlers.

    Check out the fiddle I made here

    FYI – the hover events act weird when you have complex inner content. ( for example, div within another div and so on ). I advise you to use “mouseenter” and “mouseleave”

    UPDATING ANSWER AFTER REALIZING THIS IS A DROP DOWN MENU QUESTION

    The drop down menu in CSS is a great example where “hover” won’t suffice –> because the submenu disappears once you’re not on the link anymore.. and that’s not what we want.

    It is important to note 3 things about drop down menus :

    1. They can (?should?) be achieved purely with CSS
    2. The HTML structure is important.

    For example, consider the following structure instead :

    <ul class="menu">
        <li>
        </li>
        <li>
            <ul class="menu">
             <li>
             </li>
            </ul>
        </li>
    </ul>
    

    This structure is recursive – you can have infinite levels of submenus – and the mouseenter/mouseleave on the “li” will hold since the submenu is part of the “li” item.

    To see this in action have a look in my fiddle

    Please also note that I removed the first “hide” from the onload code, and replaced it with css “display:none” – which resolves flickering on page load ( flickering means – first the submenu shows, and once the page loads, we hide it. )

    A css solution would include a selector with “hover” on it ( yes, hover.. )

    You can find plenty of blog posts about it while searching in google.

    Here is the first one I found.

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

Sidebar

Related Questions

I'm trying setup a map that displays different pin colors depending on the type/class
I am trying to setup a directory that contains Perl modules that should be
I am trying to setup something that looks like this with the arrow that
Hi I'm trying to setup a RegexpValidator that only accepts a string of alphanumeric
I am trying to setup a form that takes in some song information. Right
I'm trying to debug an MS-Build in VS2010 setup that reports about a half-dozen
In C#.net, I have the following DataSource setup that I am trying to dynamically
I'm using Rails 3.1, and trying to setup Recaptcha so that it only shows
I am trying to setup a simple proxy server that we post the data
I'm trying to setup a simple timer that gets started from a Rails Application.

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.