Percentage Animate

by Hugo Carneiro

HTML

<span class="score"></span>
<br/>
<span class="percentage"></span>

JavaScript

var resultValue = "226";
	var minValue = "0";
	var maxValue = "226";
	var percentage = "100";
	
	$({countNum: minValue}).delay(1200).animate({countNum: resultValue}, {
		duration: 1000,
		easing:'swing',
		step: function() {
			$('.score').html(Math.ceil(this.countNum) + "<span>/" + maxValue + "</span>");
		},
		complete: function() {
			setTimeout(function(){
				
				$('.percentage').html((percentage >= 50 ?  Math.floor(percentage): Math.ceil(percentage))  + "%").addClass('animated');
			}, 200);
		}
	});