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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:52:50+00:00 2026-06-11T17:52:50+00:00

I am currently displaying pictures when an tag is hover over. I have been

  • 0

I am currently displaying pictures when an tag is hover over. I have been able to workout the main problem of displaying the picture. The problem is that it has a glitch when hovering occurs quickly. Is there away to avoid that? Also how can i set a default image to display when page is loaded? JSFIDDLE

HTML

<div id="links">    
    <a href="example.htm" class="large magenta awesome" data-content="cheeseburger">Cheeseburger »</a>
    <a href="example.htm" class="large blue awesome" data-content="tacos">Tacos »</a>
    <a href="example.htm" class="large red awesome" data-content="salads">Salads »</a>
    <a href="example.htm" class="large orange awesome" data-content="bread-sticks">Bread Sticks »</a>
    <a href="example.htm" class="large yellow awesome" data-content="dessert">Dessert »</a>
</div>

Jquery

$("div#links > a").hover(
    function(){
        var ID = $(this).data("content");
        $("div#images").children("img#" + ID).fadeIn("slow");
    },
    function() {
        var ID = $(this).data("content");
        $("div#images").children("img#" + ID).hide();
    }
);​

Glitch

enter image description here

  • 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-11T17:52:52+00:00Added an answer on June 11, 2026 at 5:52 pm

    The problem is that it has a glitch when hovering occurs quickly. Is
    there away to avoid that?

    This is not a glitch. fadeIn is using animation. As you are hovering over the links faster than the animations complete your experiencing that “glitch”.

    To ensure you are not clashing with the previous running animation you have to stop any current and any queued animation.

    Replace

    $("div#images").children("img#" + ID).fadeIn("slow");
    

    with

    $("div#images").children("img#" + ID).stop(true, true).fadeIn("slow");
    

    DEMO – Clearing the animation queue before starting the next one

    how can i set a default image to display when page is loaded?

    I added the code to show a default image as well. To prevent any odd visuals when hovering over a menu item the first time when using a default image. The code checks if we are showing a default image and if we are it will further check if the image for the current menu is the default image.

    If it is, it won’t hide it as it is showing it anyway but if it is not, it will ide the default image before fading in the new one.

    Hope this makes sense, see the full code and DEMO below.

    // Indicates if default image is shown
    var showingDefaultImage = true;
    
    var $images = $("div#images");
    var $defaultImage = $images.children("img#tacos");
    
    // Display a default image
    $defaultImage.show();
    
    $("div#links > a").hover(
    
    function() {
        var ID = $(this).data("content");
        var $image = $images.children("img#" + ID);
    
        if (showingDefaultImage) {
            showingDefaultImage = false;
            if (!$image.is($defaultImage)) {
                $defaultImage.hide();
            }
        }
    
        $image.stop(true, true).fadeIn("slow");
    }, function() {
        $images.children().hide();
    });​
    

    DEMO – Showing a default image

    The code in the above DEMO is also a little more optimized by caching the selectors.

    would it be possible to leave up the most recent image from the last
    hovered tag ?(instead of hiding the image and leaving a blank)

    If I understood you correctly you don’t want to hide the image when you leave menu with your mouse but instead want to leave the image of the menu you last hovered over visible.

    To do that you remove the second function of the hover and as it is no longer needed you can now attach the mouseenter event instead.

    var $images = $("div#images");
    var $currentImage = $images.children("img#tacos");
    
    $currentImage .show();
    
    $("div#links > a").mouseenter(function() {
        var ID = $(this).data("content");
        var $image = $images.children("img#" + ID);
    
        if (!$image.is($currentImage)) {
            $currentImage.hide();
        }
    
        $currentImage = $image;
        $image.stop(true, true).fadeIn("slow");
    });
    

    DEMO – Fading in images on mouseenter and leaving last image visible

    The above code includes caching of selectors for optimisation and the logic to ensure no “flickering” occurs when the new hovered menu item is the same as the last one which was hovered.

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

Sidebar

Related Questions

I currently have my instance of Datepicker displaying the Button Bar panel that includes
I have a UILabel that is currently displaying the value on a UISlider as
I have a DateTimePicker and it is currently displaying Friday, June 26 2009 How
Currently I have 2 ways of displaying images in a cell, which way will
I'm currently designing an app that calls for dynamically creating objects and then displaying
So I have a listview that is displaying correctly. When the item is turned
I currently have a simple list view adapter that holds two rows of text.
I created an object that extends android.view.View , overriding draw() and have it displaying
I have some (OpenCV) code that generates images. I'm displaying these using OpenGL. When
I have a flash object which im currently displaying with 100% width & height

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.