0

我从来没有使用jQuery UI进度条,但我想制作一个基本上会加载jQuery UI进度条的函数,运行它5秒钟,然后执行另一个函数。jQueryUI进度条

即。

function test() { 

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

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

} 

这怎么办?

回答

0

你可以这样说:

​<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 Example