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

  • Home
  • SEARCH
  • 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 6784755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:02:14+00:00 2026-05-26T17:02:14+00:00

I have a mouseover / mouseout handler. Both use Javascript timeout to delay their

  • 0

I have a mouseover / mouseout handler. Both use Javascript timeout to delay their job. But mouseout event triggers even when mouse is still over the selector. It works normally when timeout is turned off in mouseout script. So I suppose I do something wrong about timeout. It is something like

      $('.selector').live( {mouseover : function() {
          var timeout = setTimeout(function() {
        $('.something' ).show();
          }, 1000);
    }, mouseout: function () {
          timeout = setTimeout(function() {
        $('.something' ).hide();    
          }, 2000);
    }
      });

Same thing happens if I use hover handler instead of mouseover / mouseout. And same thing if I use different variable names for two timeouts, or if I clear one timeout before calling another. What do I do wrong?

  • 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-26T17:02:15+00:00Added an answer on May 26, 2026 at 5:02 pm

    Since it works normally without timeouts I assume mouseover/mouseout is the correct event for you instead of mouseenter/mouseleave.

    You are calling multiple timeouts constantly which are firing all over the place, you need to use a single timer that is only timing a single thing at one time:

    (function () {
    var timeout = 0;
        $('.selector').live({
        mouseover: function () {
        window.clearTimeout( timeout );
            timeout = setTimeout(function () {
            $('.something').show();
            }, 1000);
        },
        mouseout: function () {
        window.clearTimeout( timeout );
            timeout = setTimeout(function () {
            $('.something').hide();
            }, 2000);
        }
        });
    })()
    

    window.setTimeout just returns an ordinary integer number. Each time you call window.setTimeout a new timer will be created regardless of what variable the return value is assigned to. The return value of window.setTimeout can be used to clear a specific timer.

    As a side effect, you can clear timeouts that you don’t even know are existing. For example:

    jQuery("div").fadeOut( 15000 );
    
    var l = 10000;
    
    while( l-- ) window.clearTimeout( l );
    

    You are brute forcing 10000 different timer ids and clearing them all, taking out the jQuery fx internal timer which stops the fading out. Do not use in real code, for demonstration purposes only.

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

Sidebar

Related Questions

I have 2 event handlers: Y.all(.ptl).on(mouseover, handleOverlay); Y.all(.ptl).on(mouseout, handleOverlay); And I would like to
I have always used the mouseover event, but while reading the jQuery documentation I
I have a mouseover and a mouseout event on a menu, that shows/hides a
i have script like this $('.parent a').live('mouseover mouseout', function(event) { if (event.type == 'mouseover'){
I have a website which uses jQuery and lots of mouseover / mouseout effects.
I have this code: $(div[id^='intCell']).mouseover(function() { $(this).css({ border:,1px solid #ff097c}); }).mouseout(function() { $(this).css({border:,1px solid
I have a web page with DIV s with a mouseover handler that is
I have some javascript code that creates an img tag with a mouseover callback,
I have a site with three tabs that I'm trying to dynamically add mouseover/mouseout
jQuery 1.4.2: I have an image. When the mouseover event is triggered, a function

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.