console
var total = 1000;
var current = 588;
function getFinallyPer () {
return parseInt((current / total) * 100, 10)
}
function animateProgressBar () {
var progressBar = $('.progressBar');
var tag = $('.tag');
progressBar.animate({
width: getFinallyPer() + '%',
}, {
duration: 5000,
step: function(val) {
tag.text(parseInt(val, 10)+'%')
}
});
}
$(function(){
animateProgressBar()
})
<div class="progress">
<div class="progressBar">
<div class="tag"></div>
</div>
</div>
.progress {
width: 600px;
background: #ccc;
height: 30px;
}
.progressBar {
width: 0%;
height: 30px;
background: #f0f;
position: relative;
overflow: visible !important;
}
.tag {
position: absolute;
top: 50px;
right: 0px;
}