<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 style="background:#000;width:$.timer%;"><< here</div>
you can use jQuery UI plugin. ( with timer )
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. 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:
HTML
<div id="progressbar">0%</div>
CSS
#progressbar {
width: 0px;
background-color: blue;
color: white;
padding: 5px;
}
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();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.