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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:58:53+00:00 2026-05-31T10:58:53+00:00

I have a small jQuery snippet which animates an image caption, based on the

  • 0

I have a small jQuery snippet which animates an image caption, based on the image’s alt attribute if it exists.

It’s working fine but I have one small issue. I want a delay on the hover out (slideUp) animation, but only if the previous slideIn animation completed fully. In basic scenarios:

scenario 1: User hovers over image, caption fully animates in. User hovers out, animation delays (caption stays put) for 2 seconds, then animates out.

scenario 2: User hovers over image, caption begins to animate in, but user hovers out before it completed. Animation should immediately stop and animate out without delay.

Scenario 1 works perfectly. scenario 2 doesn’t. The delay happens on the partially animated elements before it slides out which isn’t desired. I can see the flaw in my code, but can’t seem to figure out how to address it.

Fiddle, and current script:

$('.pv-inner').hover(function() {

    var img = $(this).find('img:first');
    var text = img.attr('alt');

    if (text !== undefined) {
        //remove any existing captions
        $(this).find('.kppImageCaption').remove();

        //insert the new caption
        img.after('<div class="kppImageText">' + text + '</div><div class="kppImageCaption"></div>');

        //animate it in
        $(this).find('.kppImageCaption').stop().slideDown('slow').animate({
            opacity: 0.6
        }, {
            queue: false,
            duration: 'slow',
            complete: function() {
                $(this).parent().find('.kppImageText').fadeTo(1000, 1);
            }
        });
    }
}, function() {

    //on hover out animate it out. Here is the problem. I only want the delay 
    //to occur if the above hover over animation completed - currently it delays
    //in all cases.
    $(this).find('.kppImageCaption, .kppImageText').stop().delay(2000).slideUp('slow', function() {
        $(this).remove();
    });

});

EDIT:

Final working fiddle. May help someone down the road.

  • 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-31T10:58:54+00:00Added an answer on May 31, 2026 at 10:58 am

    Create variable, let’s call it var animationStatus = false
    Just before starting animating it it, set animationStatus = true

    in complete function (see jQuery animate docs) set animationStatus = false

    In your function which is responsible for hiding – create if statement. If animationStatus === false – delay. If animationStatus === true – without delay.

    Good luck!

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

Sidebar

Related Questions

I am using Jquery Autocomplete . Its workng fine but I have small problem.
I have a small jquery snippet that displays notification message at the top of
I used to have a small chat app(which was almost working), that uses PHP,
I'm new to jQuery and JavaScript I have managed to get a small snippet
I have a small jQuery based script for animating the border on images that
I have a small ajax jquery script which returns some XML for me. Whilst
I have a small problem with my jQuery image rotator. Basically, my rotator should
I have a small snippet of which it takes you from one tab to
peace folks, I have this small piece of jquery based code, that grabs all
I have small animation made with jQuery (panels goes up and comes down). But

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.