Thousand separator | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Thousand separator

Hello friends, Is there any simple way to insert thousand separator in numbers by CSS,JS or whatever? Eg Changing 50000 to 50,000

5th Apr 2020, 10:34 PM
Hamimu Said
3 Answers
+ 3
Not with CSS, possible with JS. https://code.sololearn.com/WZA12DQcuIPA/?ref=app
5th Apr 2020, 11:41 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 1
<!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>`substitute(Filename('', 'Page Title'), '^.', '\u&', '')`</title> <meta http-equiv="" content="" /> </head> <body> <span id="number">90000</span> <script> var numberTag = document.getElementById("number"); var num = document.getElementById("number").textContent; if(num.length > 3 && num.length < 6){ if(num.length == 4){ var bc = num.slice(0,1); var ac = num.slice(1); num1 = bc.concat(",", ac); number.innerHTML = num1; } if(num.length == 5){ var bc = num.slice(0,2); var ac = num.slice(2); num1 = bc.concat(",", ac); number.innerHTML = num1; } } </script> </body> </html>
6th Apr 2020, 6:31 AM
Akash Moradiya
Akash Moradiya - avatar
+ 1
Thank you Prometheus and Akash, bless up
6th Apr 2020, 10:32 AM
Hamimu Said