There are way too many questions and answers about this basic functionality, I cannot see the wood for the trees.
In Java there is only one simple answer (jav
Using the jQuery Number Format plugin, you can get a formatted number in one of three ways:
// Return as a string
$.number( 1234.5678, 2 ); // Returns '1,234.57'
// Place formatted number directly in an element:
$('#mynum').number( 1234.5678 ); // #mynum would then contain '1,235'
// Replace existing number values in any element
$('span.num').number( true, 2 ); // Formats and replaces existing numbers in those elements.
If you don't like the format, or you need to localise, there are other parameters that let you choose how the number gets formatted:
.number( theNumber, decimalPlaces, decimalSeparator, thousandsSeparator )
You can also get jQuery Number Format from GitHub.