0

我从未使用过 jQuery UI 进度条,但我想做一个基本上加载 jQuery UI 进度条的函数,运行 5 秒,然后执行另一个函数。

IE。

function test() {

show the jQuery UI progress bar for 5 seconds in div ("progressbar")

after 5 seconds has passed..... execute test2()

}

如何才能做到这一点?

4

1 回答 1

0

你可以这样做:

​&lt;button onclick="test()">Test</button>
<div id="progress"></div>​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​

带动画:

function test(){
    var per = 0;
    progress(per);
    time = setTimeout(function(){ animate(per); }, 1000);
    setTimeout(function(){ $( "#progress" ).hide(); test2(); }, 5000);

}

function animate(per){

    clearTimeout(time);
    per = per+20;
    progress(per);

    time = setTimeout(function(){ animate(per); }, 1000);
}

function test2(){
    alert('test2');
}
function progress(per){
    $( "#progress" ).progressbar({
        value: per
    });        
}

JSFiddle 示例

于 2012-09-11T15:57:10.227 回答