I'm currently populating a div with jquery but need to format the output with a thousands separator and to two decimal places whilst also keeping the output as a number.
FYI I'm currently populating the div using:
var prev_count = 120;
var new_count = 20.50;
var count_till = prev_count < new_count ? new_count : new_count - 1;
jQuery({ Counter: prev_count }).animate({ Counter: count_till }, {
duration: 600,
easing: 'swing',
step: function () {
jQuery("#count_div").text(Math.ceil(this.Counter));
}
});
Starting variable is 120 and this is meant to count down to 20.50 however it ends on 20, not 20.50, is this possible if so how would i go about it?
Here is my jsfiddle