Phillip Senn
Phillip Senn

Reputation: 47625

Trying to delay an animation on startup

I have:

$(window).one('load',function() {
    setTimeout(function() { 
        $('.slider').slideToggle('slow'),
        15000 
    });
});

I'm trying to limit the animation to only once so as not to get annoying. The problem is: it's not waiting 15 seconds. It animates immediately.

Upvotes: 0

Views: 126

Answers (3)

Felipe Sabino
Felipe Sabino

Reputation: 18215

The comma is in the wrong place.

The time is a parameter from setTimeout function

$(window).one('load',function() {
    setTimeout(function() { 
           $('.slider').slideToggle('slow');
        },
      15000);
});

Upvotes: 1

cwallenpoole
cwallenpoole

Reputation: 82028

I'm actually surprised that this compiles (or rather, does not yell at you) -- you misplaced a '}'.

setTimeout(function() { 
        $('.slider').slideToggle('slow')
    }, // <-- right there!
    15000 
);// <-- not there!

Upvotes: 2

glortho
glortho

Reputation: 13198

$(window).one('load',function() {
    setTimeout(
        function(){$('.slider').slideToggle('slow')},
        15000 
    );
});

Upvotes: 2

Related Questions