[英]Jquery time how to make a progressbar
<script type="text/javascript">
var count = 0;
var timer = $.timer(
function() {
count++;
$('.count').html(count);
},
1000,
true
);
</script>
How can i make a progressbar with timer ? 如何使用计时器制作进度栏? Example every second add to div with 示例每秒添加到div
<div style="background:#000;width:$.timer%;"><< here</div>
you can use jQuery UI plugin. 您可以使用jQuery UI插件。 ( with timer ) (带计时器)
https://jqueryui.com/progressbar/ https://jqueryui.com/progressbar/
<script>
var v = 0;
var upProgress = function() {
v++;
$( "#progressbar" ).progressbar({
value: v
});
setTimeout( upProgress , 1000 );
};
$(function() {
setTimeout( upProgress , 1000 );
});
</script>
</head>
<body>
<div id="progressbar"></div>
</body>
</html>
PS. PS。 Try exploring the new progress element ;) 尝试探索新的进度元素;)
$("progress").animate({v:1}, { duration: 5000, step: function(v){ this.value = v } });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <progress min="0" max="1">
If you don't want to use jQuery: 如果您不想使用jQuery:
HTML HTML
<div id="progressbar">0%</div>
CSS CSS
#progressbar {
width: 0px;
background-color: blue;
color: white;
padding: 5px;
}
JS JS
function progressBar() {
var progress = 1, timer, percent;
var bar = document.getElementById('progressbar');
var loop = function loop (progress) {
if (progress === 11) {
clearTimeout(timer);
} else {
percent = progress * 10;
bar.style.width = percent + 'px';
bar.textContent = percent + '%';
timer = setTimeout(loop, 1000, ++progress);
}
}
loop(progress);
}
progressBar();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.