Cameron
Cameron

Reputation: 28803

jQuery delay start function

I'm using the jQuery Cycle plugin to cycle through some words, but I don't want it to start or show any of the words until a few seconds after page load, perhaps 10 seconds or so.

This is the code I have:

$(document).ready(function() {

 $('#questions').cycle({ 
    delay:  10000, 
    speed:  2000
});
});

What would be the best way to wait 10 seconds and then run the cycle function and also show the content that will be hidden by default. Thanks.

Upvotes: 2

Views: 4566

Answers (2)

Sarfraz
Sarfraz

Reputation: 382706

You can use the setTimeOut() function:

$(function(){
  setTimeOut(function(){
    $('#questions').cycle({ 
        delay:  10000, 
        speed:  2000
    });
  }, 5000)
});

Upvotes: 0

Coin_op
Coin_op

Reputation: 10718

Just use the javascript setTimeout function.

setTimeout(function(){
    $('#question').cycle({ speed: 2000 });
    // Other code to show whatever you want goes here, ie. $('some selector').show();
}, 10000);

Upvotes: 4

Related Questions