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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:58:07+00:00 2026-06-04T10:58:07+00:00

I’m trying to create two buttons that using the hover event, hide some divs

  • 0

I’m trying to create two “buttons” that using the hover event, hide some divs and then display some others in their place. I’m then trying to delay the swapping back to the default div.

All works, fine, unless you go from one button to the other at which point you get many divs displaying at the same time until the delay passes. If we don’t use the delay it works perfectly.

The javascript:

jQuery(function ($) {

$('#servers-btn').hover(
   function() {
    $('#servers, #servers-heading, #servers-arrow').show(0);
    $('#default, #default-heading').hide(0);
   }, 
   function() {
   setTimeout( function() {
        $('#servers, #servers-heading, #servers-arrow').hide(0);
        $('#default, #default-heading').show(0);
        },1000)
    }
);

$('#hosting-btn').hover(
   function() {
    $('#hosting, #hosting-heading, #hosting-arrow').show(0);
    $('#default, #default-heading').hide(0);
   }, 
   function() {
   setTimeout( function() {
        $('#hosting, #hosting-heading, #hosting-arrow').hide(0);
        $('#default, #default-heading').show(0);
        },1000)
    }
);

});

I assume i need to make one hover function aware of the other so it can cancel the timeout, i just have no clue how to do it.

EDIT – just tidyed up code to put all divs into one hide/show.

Also, i should have probably mentioned that the #default, #servers and #hosting divs appear in exactly the same location. So need to instantly switch at the same time (which the above does).

EDIT – latest attempt to use clearTimeout here http://jsfiddle.net/KH4tt/1/ – but can’t quite make it work right.

  • 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-04T10:58:09+00:00Added an answer on June 4, 2026 at 10:58 am

    Ok here’s the final thing using the clearTimeout() function to cancel the setTimeout() that is used on mouseleave (hover handlerOut) that creates the delay:

    jQuery(function($) {
    
    var timeoutserver;
    
    function canceltimeout() {
    if (timeoutserver) {
        window.clearTimeout(timeoutserver);
        timeoutserver = null;
    }
    }
    
    function closeServertime() {
        timeoutserver = window.setTimeout(function() {
            $('#servers, #servers-heading, #servers-arrow').hide(0);
            $('#default, #default-heading').show(0);
        }, 1000);        
    }
    
    function closeHostingtime() {
        timeoutserver = window.setTimeout(function() {
            $('#hosting, #hosting-heading, #hosting-arrow').hide(0);
            $('#default, #default-heading').show(0);
        }, 1000);        
    }
    
    
    $('#servers-btn').hover(
    
    function() {
        canceltimeout();
        $('#servers, #servers-heading, #servers-arrow, ').show(0);
        $('#default, #default-heading, #hosting, #hosting-heading, #hosting-arrow').hide(0);
    }, function() {
        closeServertime();
    });
    
    $('#hosting-btn').hover(
    
    function() {
        canceltimeout();
        $('#hosting, #hosting-heading, #hosting-arrow').show(0);
        $('#default, #default-heading, #servers, #servers-heading, #servers-arrow').hide(0);
    }, function() {
        closeHostingtime();
    });
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP 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.