zadubz
zadubz

Reputation: 1301

How to add delay to a function

$(function(){
    $('#slides_left').slides({
        generateNextPrev: false,
    play: 5500
    });
});

How can I add a .delay() to the function above so that the starting time for the function is not onload rather to a specified time?

sorry for my noobness in jQuery!

Thanks!

Upvotes: 0

Views: 306

Answers (3)

PiTheNumber
PiTheNumber

Reputation: 23542

$(function(){
    // Start after 3 seconds
    window.setTimeout('doSlide()', 3000);
});

function doSlide(){
    $('#slides_left').slides({
        generateNextPrev: false,
        play: 5500
    });
};

There is also a pause option for slides().

Upvotes: 2

Curtis
Curtis

Reputation: 103338

Use setTimeout

$(function(){
    setTimeout(function(){
      $('#slides_left').slides({
         generateNextPrev: false,
         play: 5500
      });
    }, 1000);
});

Upvotes: 1

Rahul Choudhary
Rahul Choudhary

Reputation: 3809

you can use javascript setTimeOut function

setTimeout(functionname, 2000); // replace 2000 with your number of millisecond required for delay.

Call this setTimeout inside onload.

Cheers!!

Upvotes: 5

Related Questions