Counter-Up
Counter-Up copied to clipboard
Numbers with spaces
Is it possible to add support for numbers with spaces as thousand separator? (e.g. 123 456)
I've found a little solution,
on line 50 of jquery.counterup.js you will find:
newNum = newNum.toString().replace(/(\d+)(\d{3})/, '$1'+','+'$2');
Replace by this:
newNum = newNum.toString().replace(/(\d+)(\d{3})/, '$1'+' '+'$2');
For working, you need to use the comma (,) in the html
In my fork I merged a bunch of PRs - it's already on bower and NPM. You can get this with the new "formatter" option:
$('.counter').counterUp({
delay: 100,
time: 1600,
formatter: function (n) {
return n.replace(/,/g, ' ');
});