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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:07:22+00:00 2026-06-05T06:07:22+00:00

I am currently creating a site with some dynamic content, so that whenever a

  • 0

I am currently creating a site with some dynamic content, so that whenever a user hovers over a label, the label expands to show more information, then after a specific time the label will collapse again, unless the user hovers over the label again in which case the Timeout will reset. I have developed the code to do this for 1 label, but I would to develop it now to do it for multiple labels.

The problem I’m having though is that I am defining the variable for the timer globally so it can be used for both events, this won’t work when I have multiple labels though.

I can’t think how I can achieve this for multiple labels, does anyone have any idea how I can do this?

Here is my code so far…

    var timer;


    $('.label').mouseenter(function(){

        clearTimeout(timer);

        $('#' + this.id + ' div').slideDown('slow');

    });


    $('.label').mouseleave(function(){

        var temp = $('#' + this.id + ' div');

        timer = setTimeout(function() { 
            temp.stop().slideUp('slow');
        }, 2000);

    }); 

Thanks in advance for any help.

  • 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-05T06:07:26+00:00Added an answer on June 5, 2026 at 6:07 am

    You can maintain an array of timers like

    var timer = [];
    
    
    $('.label').mouseenter(function(){
    
        clearTimeout(timer[$(this).index()]);
    
        $('#' + this.id + ' div').slideDown('slow');
    
    });
    
    
    $('.label').mouseleave(function(){
    
        var temp = $('#' + this.id + ' div');
    
        timer[$(this).index()] = setTimeout(function() { 
            temp.stop().slideUp('slow');
        }, 2000);
    
    }); 
    

    You can also achieve this with a more clear syntax using .hover like

    var timer = [];
    
    $('.label').hover(function(){
    
        clearTimeout(timer[$(this).index()]);
    
        $('#' + this.id + ' div').slideDown('slow');
    
    },function(){
        var temp = $('#' + this.id + ' div');
    
        timer[$(this).index()] = setTimeout(function() { 
            temp.stop().slideUp('slow');
        }, 2000);
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently creating a site for a musician. They are wanting to include the
I am currently in the process of creating a new news/publishing site on the
I'm currently creating a small C# program that inserts data from files into a
I am creating a silverlight site. I am currently breaking out my ideas into
I've been tasked with creating an extremely heavy JavaScript site that of course must
At the moment, I am creating some kind of admin panel/backend for my site.
I need some help with rally. I'm currently looking at creating a simple app
I have an ASP.NET web site which contains some ImageButton controls that cause postbacks
I'm currently creating a CMS system and found that the following doesn't work. I
I have been asked about creating a site where some users can upload Microsoft

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.