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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:46:45+00:00 2026-05-14T03:46:45+00:00

I have 2 divs above each others, at a given moment one is shown

  • 0

I have 2 divs above each others, at a given moment one is shown and the other is hidden, the script should display #div2 when the mouse enters #div1 and should show #div1 when the mouse leaves #div2

the problem comes when the mouse enters #div1 and leaves before #div2 is displayed so the #div2 will stay displayed but the mouse has left #div2 already
any help ?

My jQuery code:

$('#div1').mouseenter(function(){
 $('#div1').fadeOut("fast",function(){
  $('#div2').fadeIn("fast");
 });
});

$('#div2').mouseleave(function(){
 $('#div2').fadeOut("fast",function(){
  $('#div1').fadeIn("fast");
 });
});
  • 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-14T03:46:46+00:00Added an answer on May 14, 2026 at 3:46 am

    I would suggest using hover() here:

    $("#div1, #div2").hover(function() {
      $(this).stop().fadeOut("fast");
    }, function() {
      $(this).stop().fadeIn("fast");
    });
    

    Note: I’ve used stop() on the animations, which is a good habit to get into. The above version also allows both divs to have the same handler, which reduces your code.

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

Sidebar

Related Questions

I have two divs that are right above each other. The bottom one has
http://jsfiddle.net/pC6fC/1/ I have two divs, one above the other. When the first animates, which
I have a wrapper div which contans 2 divs next to each other. Above
I have two sibling divs sitting below each other, both contained in the same
I have two div's, one above the other and both have a table inside
I have Divs show and hide (with an animation) using the following script (I
I have divs that I want to display at specific times throughout the day.
I have two divs floated next to one another: <div id=parent> <div id=child_1 style=float:left>
I have a bunch of divs with weird id and each of them contains
I have two DIVs that I need to position exactly on top of each

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.