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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:14:30+00:00 2026-05-27T08:14:30+00:00

I have a link. When I hover over it, there should be a delay

  • 0

I have a link. When I hover over it, there should be a delay of 1-2 seconds, after which a div will appear. The div should stay when I hover over it.

If I am not hovering on either the link or the div, the div should disappear after a delay of 1-2 seconds.

I’m not sure how to accomplish this. Could someone help? What I’m trying to achieve is similar to how Google sows previews of websites.

var formHide;
$('.toggleDisForm').hover(function() {
   var form = $(this).parents("li").find(".dispenserForm");
   function showIt() {
      form.fadeIn();
   }
   show = setTimeout(showIt, 1000);
   clearTimeout(formHide);
}, function() {
   var form = $(this).parents("li").find(".dispenserForm");
   function hideIt() {
      form.fadeOut();
   }
   clearTimeout(show);
   hideDispen = setTimeout(hideIt, 1000);
   $('.dispenserForm').not(form).hide();
});

var hideDispen;
$('.dispenserForm').hover(function() {
   $('.dispenserForm').not(this).hide();
   clearTimeout(hideDispen);
}, function() {
   var form = $(this);
   function showMe() {
      form.show();
   }
   formHide = setTimeout(showMe, 1000);
});

Her is the markup

<ul class="clearfix">       
    <li>
        <div class="inner">
            <a class="toggleDisForm" href="#">hover
                       <div class="dispenserForm">
                The div that should appear
                  </div>
                    </a>
        </div>

    </li>

    <li>
        <div class="inner">
            <a class="toggleDisForm" href="#">hover
                       <div class="dispenserForm">
                The div that should appear
                  </div>
                    </a>
        </div>
    </li>

    <li>
        <div class="inner">
            <a class="toggleDisForm" href="#">hover
                       <div class="dispenserForm">
                The div that should appear
                  </div>
                    </a>
        </div>
    </li>

    etc...      
</ul>
  • 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-27T08:14:31+00:00Added an answer on May 27, 2026 at 8:14 am

    The code you have posted isn’t working because code inside setTimeout is run in the global scope. this no longer refers to the same thing anymore. Try something like this:

    $('.toggleDisForm').hover(function() {
       var form = $(this).parents("li").find(".dispenserForm");
       function showIt() {
          form.show();
       }
       show = setTimeout(showIt, 2000);
    }, function() {
       clearTimeout(show);
       $('.dispenserForm').hide();
    });
    

    In general, it’s better practice to use setTimeout this way (with a function instead of a string).

    EDIT: In response to your comment, let’s see if we can get it to hang around a little bit after it’s shown.

    var formHide;
    $('.toggleDisForm').hover(function() {
       var form = $(this).parents("li").find(".dispenserForm");
       function showIt() {
          form.show();
       }
       show = setTimeout(showIt, 2000);
       clearTimeout(formHide);
    }, function() {
       var form = $(this).parents("li").find(".dispenserForm");
       function hideIt() {
          form.hide();
       }
       clearTimeout(show);
       hide = setTimeout(hideIt, 1500);
       $('.dispenserForm').not(form).hide();
    });
    $('.dispenserForm').hover(function() {
       $('.dispenserForm').not(this).hide();
       clearTimeout(hide);
    }, function() {
       var form = $(this);
       function hideMe() {
          form.hide();
       }
       formHide = setTimeout(hideMe, 500);
    });
    

    Does that work?

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

Sidebar

Related Questions

I have a popup that is displayed above the link when I hover over
For text links, I have: CSS: a:link {color: #3366a9; text-decoration: none} a:hover {border-bottom: 1px
I have a link that I dynamically create which looks something like the following:
I have a link in a pdf-document (PDF1), which is embedded in a browser
I have a link to a page which invokes the 'Sexy Alert Box' script
I think I am being particularly stupid. I have a link, which is part
I have a menu in which each anchor should do a simple color fade
I have a link: <a href=# id=link>Here's my link</a> This is not a normal
I have three links, Cat, Dog, Snakes. When I hover over each, the content
I have an image which is has an onmousedown event . When I hover

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.