Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript How to callback properly? (and timeout)

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #23843
    Oskar
    Participant

    Hi all,

    I’m having some trouble understanding how the callback works. This is a quite simple example, doesn’t work as I want it to though. My idea is that box2 should animate back when the two first (and simoltaneous, spelling) animations complete, however it doesn’t.

    Another question is how will I delay the callback by say two seconds? And is it possible to loop this over and over again?

    Code:
    $(‘#elevator’).click(function(){
    $(‘#box1’).animate({width: 250, height: 300}, 1000);
    $(‘#box2’).animate({width: 200, height: 300}, 1000);
    }, function(){
    $(‘#box2’).animate({width: 300, height: 10}, 1000);
    }
    );
    #53443
    eshhy
    Member

    I wouldn’t even class myself a beginner with jQuery, thats why I always look at the documentation.

    Go to their site and search those specific terms (call backs, delays, queue), study all there examples carefully. I know everytime I have a problem, I always use this process.

    Hope this helps in some indirect way.

    #53498
    Rob MacKay
    Participant

    you could try this…

    Code:
    $(‘#elevator’).click(function(){
    $(‘#box1’).animate({width: 250, height: 300}, 1000);
    $(‘#box2’).animate({width: 200, height: 300}, 1000)
    .animate({width: 300, height: 10}, 1000);
    }
    );

    bit of a random guess tbh lol

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.