开发者

prettyphoto add delay

开发者 https://www.devze.com 2023-02-22 18:39 出处:网络
I have currently installed prettyphoto and managed to launch an iframe on page load through $(document).ready(function(){

I have currently installed prettyphoto and managed to launch an iframe on page load through

$(document).ready(function(){
开发者_如何转开发

What is the quickest way to add a delay to it?


The window.setTimeout function in javascript is easy to use.

You probably do something like

$(document).ready(function(){
    $('#photo').prettyphoto(); //Not sure how you call prettyphoto
}

Add a delay before you make your call :

$(document).ready(function(){
    //The call to callPrettyPhoto will only be made after 1 second
    window.setTimeout(callPrettyPhoto, 1000 );
});

function callPrettyPhoto() {
    $('#photo').prettyphoto();
}

Note that you can also put the function inline if you wish to do so :

$(document).ready(function(){
    window.setTimeout(function() {
        $('#photo').prettyphoto();
    }, 1000);
});
0

精彩评论

暂无评论...
验证码 换一张
取 消