倒数计时器 Countup

Countdown timer to Countup

大家好,我有这个倒计时脚本,但我希望它进行计数,而不是更新 div 跨度,而是更新进度条的值。

HTML

<progress value="**UPDATE THIS**" max="780"></progress>

脚本

var sec = $('#update span').text(), secInit = sec;
        var timer = setInterval(function() {
            $('#update span').text(--sec);
            if (sec == 0) {
                sec = secInit;
                $.ajax({
                    url: "{{ url('/user/update') }}",
                    type: "GET",
                    data: { 'id' : {{ Auth::user()->id }} }
                });
            }
        }, 1000);

有什么想法吗?

谢谢, 蒂亚戈

给进度条一个ID,例如

<progress id="progress-bar" value="**UPDATE THIS**" max="780"></progress>

并使用一些 javascript 每秒更改值,例如。

var timer = setInterval(function() {
            var progbar = document.getElementById("progress-bar");
            progbar.value = progbar.value < 780 ? +progbar.value + 1 : 0;
        }, 1000);

Fiddle