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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:17:18+00:00 2026-05-26T09:17:18+00:00

HTML <div id=div-1>I’m div-1</div> <div id=div-2>I’m div-2</div> JS $(#div-1).bind(‘mouseover’,function(event){ $(‘#div-2’).stop(true,true).fadeIn(100); }); $(‘#div-2’).bind(‘mouseleave’, function(e) {

  • 0

HTML

<div id="div-1">I'm div-1</div>
<div id="div-2">I'm div-2</div>

JS

$("#div-1").bind('mouseover',function(event){
  $('#div-2').stop(true,true).fadeIn(100);
});
$('#div-2').bind('mouseleave', function(e) {
  $(this).stop(true,true).fadeOut(100);
});

My question is : How can I fadeOut the #div-2 If I mouseleave in the #div-1 ?
I’m currently using jquery 1.2.6 and I can’t change the version.

EDIT

jsfiddle example

  • 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-26T09:17:18+00:00Added an answer on May 26, 2026 at 9:17 am

    SOLUTION 1 :

    You could wrap your elements and add event handlers on that wrapper.
    This way you avoid the different elements mousein/mouseout event handlers conflict:

    HTML :

    <div id="wrapper">
        <div id="div-1">I'm div-1</div>
        <div id="div-2">I'm div-2</div>
    </div>
    

    JS :

    $('#wrapper').hover(
        function(){$('#div-2').stop().fadeIn(100);},
        function(){$('#div-2').stop().fadeOut(100);}
    );
    

    Here’s a live demo :

    http://jsfiddle.net/gion_13/JUFDA/2/

    SOLUTION 2 :

    If you have multiple elements on which you want to bind the same event-handlers, you could try something like listening to the event on the whole document and matching the event’s target with your selected elements. If the event is targeted on your elements do something (fadeIn), else do something else (fadeOut) :

    var el = $("#div-1,#div-2").get();
    $(document).bind('mouseover', function(event) {
        var f = el.indexOf(event.target) === -1
            ? 'fadeOut'
            : 'fadeIn';
        $('#div-2').stop(true, true)[f](100);
    });
    

    Here’s a live demo :

    http://jsfiddle.net/gion_13/JUFDA/1/

    I know this is not the optimal solution, but it might come in handy if you want to extend your functionality over other dom elements as well.

    SOLUTION 3 :

    You could delay the execution of your mouseleave event handler on the first div, this way allowing the event handlers to execute in a different order :
    from :

    1. $('#div-1').mouseleave()
    2. $('#div-2').mouseover()
      to :
    3. $('#div-2').mouseover()
    4. $('#div-1').mouseleave()
      In this way you avoid the event-handlers conflict and, because the animation duration is very little (0.1 seconds), the delay on the first div’s mouseleave event handler execution is not noticeable :

    $("#div-1")
        .bind('mouseover',function(event){
            $('#div-2').stop(true,true).fadeIn(100);
        })
        .bind('mouseleave',function(){
            setTimeout(function(){
                if(!$('#div-2').data('over_second'))
                     $('#div-2').stop(true,true).fadeOut(50);
            },50);
        });
    $('#div-2')
        .bind('mouseover',function(event){
            $(this)
                .stop(true,true)
                .fadeIn(100)
                .data('over_second',true);
        })
        .bind('mouseleave', function(e) {
            $(this)
                .stop(true,true)
                .fadeOut(100)
                .removeData('over_second');
        });
    


    Here’s a live demo :

    http://jsfiddle.net/gion_13/JUFDA/3/

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

Sidebar

Related Questions

$(function() { var div = $('div'); $('input').click(function() { if($(this).is(':checked')) { div.html(div.text() += 49); }
$(this).parent().parent() .children(this.attr(tagName).toLowerCase()) .css(background-color, yellow); xpath: /html/body/div/table/tr/td/b/a $(this).tagName is Anchor <a> the problem with this
Further to this suggestion HTML div height auto I used Floating DIV in my
I have the following HTML DIV which does not work using FadeIn in IE:
I've this piece of HTML: div.content div.one content div.two content div.three content I want
How can I obtain this structure with HTML div 's? The first div on
I have this html div tag defined: <div style=height:100px; width:100px class=total-title> first text </div>
I use HTML DIV tag to format my header with border like this: <h3
My HTML looks like and js looks like this: <div class=container></div> var html =
I have few div HTML elements and i am cloning it with a clone(true)

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.