I have a certain number and I use counter jquery function so that the number will animate from 0 to that number in a certain period of time. Now, the problem is when I add ,(comma) or .(dot) to the number as a thousand separator, it does not work. How do I make the script work with ,(comma) and .(dot) separator and get the result back with the ,(comma) and .(dot) too ?
html
<div class='number_container'>
<span class='count'>317249</span>
</div>
css
.number_container {
background: red;
width: 100px;
text-align: center;
padding: 38px 0;
border-radius: 50px;
color: white;
margin: 0 auto;
}
.count {
font: 20px arial;
}
Js
$(document).ready(function() {
$('.count').each(function() {
$(this).prop('Counter',0).animate({
Counter: $(this).text()
}, {
duration: 3500,
easing: 'swing',
step: function(now) {
$(this).text(Math.ceil(now));
}
});
});
});
Jsfiddle Preview
https://jsfiddle.net/y6zdmaeq/
I want the number 317249 to be displayed as 317,249 or 317.249 and count up from 0. Thank you