0

i have a simple int like "77600" I want to convert it to "77 600" (basically i need to add a simple whitespace after thousands).

tmp_total = parseInt(tmp_total,10); //77600
tmp_total  = ...here goes some magic...;
$('#chekout_total #total').text(tmp_total);
Andrew Bro
  • 471
  • 2
  • 6
  • 20

1 Answers1

0

try this:

tmp_total = parseInt(tmp_total,10); //77600
tmp_total  = tmp_total.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, '$1 ');
$('#chekout_total #total').text(tmp_total);

Hope this will help you! :)

darkvirus24
  • 109
  • 2
  • 9