我有一个进度条,我在许多迭代循环中更新.
https://jsfiddle.net/k29qy0do/32/ (在单击开始按钮之前打开控制台)
var progressbar = {};
$(function () {
progressbar = {
/** initial progress */
progress: 0,
/** maximum width of progressbar */
progress_max: 0,
/** The inner element of the progressbar (filled box). */
$progress_bar: $('#progressbar'),
/** Set the progressbar */
set: function (num) {
if (this.progress_max && num) {
this.progress = num / this.progress_max * 100;
console.log('percent: ' + this.progress + '% - ' + num + '/' + this.progress_max);
this.$progress_bar.width(String(this.progress) + '%');
}
},
fn_wrap: …Run Code Online (Sandbox Code Playgroud) 我有HTML代码.我需要一些javascript代码在每次迭代时更新值
<progress id="progressBar" max="100" value="0"></progress>
for (i = 0; i <= 100; i ++) {
//update progress bar
}
Run Code Online (Sandbox Code Playgroud)
我尝试做这样的事情:
var progressBar = document.getElementById("progressBar");
progressBar.value += i;
Run Code Online (Sandbox Code Playgroud)
但这不起作用.它在循环完成时更新进度条.