gpt4 book ai didi

javascript - 时间计数器进度条

转载 作者:行者123 更新时间:2023-11-28 01:57:03 27 4
gpt4 key购买 nike

在我的 php 应用程序中,我获取事件剩余的秒数:例如:6000 秒。以及从事件创建到结束的总时间。例如:10000 秒。我想做一个进度条,以秒为单位,每一秒都实现进度条。

基本上,我尝试使用 progressbar()、setInterval() 但我需要帮助才能做到这一点。

$(function() {
var initial = 6000 // need to add seconds to this value every second.
$( "#progressbar" ).progressbar({
value: initial,
max: 10000
});

});

FIDDLE

最佳答案

尝试此操作并将值调整为您想要的值:

$(function () {
var current;
var max = 10000;
var initial = 6000;
$("#progressbar").progressbar({
value: initial,
max: max
});

function update() {
current = initial; //the value on each function call
$("#progressbar").progressbar({
value: current
});
if (current >= max) clearInterval(interval);
initial += 1000; //choose how fast to the number will grow
console.log(current);
};
var interval = setInterval(update, 1000); //choose how fast to update
});

演示 here

关于javascript - 时间计数器进度条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18966631/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com