jQueryUI Progress Bar

2019-09-07 22:02发布

I have never used the jQuery UI progress bar, but I'd like to make a function that would basically load the jQuery UI progress bar, run it for 5 seconds and then execute another function.

ie.

function test() {

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

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

}

How can this be done?

1条回答
贼婆χ
2楼-- · 2019-09-07 22:35

You can do it like this:

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

With animation:

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

查看更多
登录 后发表回答