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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:34:49+00:00 2026-05-24T12:34:49+00:00

I am using jquery to slide up an down a div. For some reason

  • 0

I am using jquery to slide up an down a div.

For some reason setTimeout is not working (looks like a function scope issue).

Not able to figure out what is wrong with the below code.
(both functions are inside $(document).ready(function(){ } )

$('.slider-thumb').click(function(){
    var source = $(this).attr("src");
    $('#image_view').css('background-image',"url("+source+")");
    $('#image_view').slideDown(1000, calbck);
    initiate_timeout();

    function calbck(){}
});

function initiate_timeout(){
    var time_out = setTimeout(function() {
        $('#image_view').slideUp(1000, calbck);
    },2000);
}
  • 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-24T12:34:49+00:00Added an answer on May 24, 2026 at 12:34 pm

    You have some JS errors and scoping issues. Why would you ever have debugging turned off when trying to troubleshoot an error? Change your code to this:

    $('.slider-thumb').click(function(){
        var source = $(this).attr("src");
        $('#image_view').css('background-image',"url("+source+")");
        $('#image_view').slideDown(1000);
        setTimeout(function() {
            $('#image_view').slideUp(1000);
        },2000);  // will start 2 seconds after slideDown starts (which is 1 second after it completes)
    });
    

    or even better, use the completion function of the first animation to set the timer:

    $('.slider-thumb').click(function(){
        var source = $(this).attr("src");
        $('#image_view').css('background-image',"url("+source+")");
        $('#image_view').slideDown(1000, setTimeout(function() {
            $('#image_view').slideUp(1000);
        },1000));  // will stay open for 1 second before sliding up again
    });
    

    Or, even better, using jQuery’s delay/queuing, you can do this:

    $('.slider-thumb').click(function(){
        var source = $(this).attr("src");
        $('#image_view').css('background-image',"url("+source+")");
        $('#image_view').slideDown(1000).delay(1000).slideUp(1000);  // delay 1 sec between effects
    });
    

    The calbck you were trying to pass to slideUp was not defined in the scope you were using it (inside of initiate_timout()). It was private to your click handler.

    jQuery probably has better ways to chain effects than using your own timer, but I see no reason why this code shouldn’t work if it matches your HTML.

    Note: if your background image wasn’t already pre-cached, it may not be loaded right away when your slideDown starts.

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

Sidebar

Related Questions

I am using jQuery. I need a div to slide down from the top
Hihi, I am trying to create a slide down menu using DIV, but hit
I am using the following piece of jQuery code: $('div#addMenu1').click(function(){ if (!menuSet1){ menuSet1 =
I'm using this: jQuery('.class1 a').click( function() { if ($(.class2).is(:hidden)) { $(.class2).slideDown(slow); } else {
I'm currently using jQuery and am looking for a way to slide an image
How do I stop and restart a slide show created using JQuery? $('#left_actual').cycle('stop'); //slide
To scroll down my chat DIV I am using the following code which is
I am using this jQuery plugin: http://api.jquery.com/slideToggle/ I have this code: <div id=panel><form action=postit.php
I have multiple divs like setted up below. I want 1 (one) JQuery function
I am building an ASP.NET MVC web application and I'm using jQuery for some

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.