我有一个起始值为 100 的 HTML5 进度条。单击该按钮时,其值将在 15 秒内减少为 0。我已经从互联网上找到的示例中修改了代码。它现在位于JSFiddle中。它现在显示进度条的百分比,但我希望它显示完成加载之前的剩余时间。我怎样才能做到这一点 ?
JS
$('#btnUpload').click(function() {
var time = 150; //15 secs
var bar = document.getElementById('progBar'),
fallback = document.getElementById('downloadProgress'),
loaded = 100;
var load = function() {
loaded --;
bar.value = loaded;
/* The below will be visible if the progress tag is not supported */
$(fallback).empty().append("HTML5 progress tag not supported: ");
$('#progUpdate').empty().append(loaded + "% loaded");
if (loaded <0) {
clearInterval(beginLoad);
$('#progUpdate').empty().append("Upload Complete");
console.log('Load was performed.');
}
};
var beginLoad = setInterval(function() {
load();
}, time);
});