javascript 每 x 秒增加一次进度条
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7657558/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
increment progressbar every x seconds
提问by Mythrillic
I basically need a jQuery UI progress bar to increment x amount every x seconds. After it reaches 100% it needs to run a function to get some content.
我基本上需要一个 jQuery UI 进度条来每 x 秒增加 x 量。达到 100% 后,它需要运行一个函数来获取一些内容。
Basically a timer.
基本上是一个计时器。
EDIT:I don't need code to fetch content. I already have that.
编辑:我不需要代码来获取内容。我已经有了。
回答by alex
回答by Salman A
Assuming that you're using the jQueryUI progressbar:
假设您正在使用jQueryUI 进度条:
var tick_interval = 1;
var tick_increment = 10;
var tick_function = function() {
var value = $("#progressbar").progressbar("option", "value");
value += tick_increment;
$("#progressbar").progressbar("option", "value", value);
if (value < 100) {
window.setTimeout(tick_function, tick_interval * 1000);
} else {
alert("Done");
}
};
window.setTimeout(tick_function, tick_interval * 1000);