i am making an animated progress bar. It's code is quite simple but the problem is that I can't figure out how to avoid repeating some jQuery code, you can see it in this Fiddle:
basically, this is what repeats:
$('.bar-value').animate({width: '+=1%'},50,function(){
var percent = $('.bar-value').width() / $('.bar-value').parent().width()*100;
var percInt = parseInt(percent);
$('.progress').text(percInt+"%");
});
that just increases the width of the inner div (progress) by 1%, and increases .progress span number by 1. Is there any way to do what i'm trying to do without repeating that code?
Thanks in advance!