bmcode
April 18, 2021, 2:14am
1
I’m using a counter that animates to a given number once the user scrolls to the div. Here is the CodePen: https://codepen.io/bmcdesign/pen/GRrBwbd
How can I add commas to the number counter? (ex. “300,000”)
If I add commas to the data-count, it returns as not a number.
Thanks to whoever can help me!
Here you go…
step: function() {
$this.text(Math.floor(this.countNum).toLocaleString());
},
complete: function() {
$this.text(this.countNum.toLocaleString());
//alert('finished');
}
Using toLocaleString will use commas for everywhere it uses them, and I believe periods for those locales that use them too. Either way, it uses the separators. Notice above how we use toLocaleString on the counts.
2 Likes
bmcode
April 19, 2021, 9:21pm
3
Worked perfectly! Thanks!
system
Closed
July 20, 2021, 4:22am
4
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.