Comma-formated numbers in jQuery
问题 I have following function in jQuery to format the number into comma-formatted: function CommaFormattedN(amount) { var delimiter = ","; var i = parseInt(amount); if(isNaN(i)) { return ''; } i = Math.abs(i); var minus = ''; if (i < 0) { minus = '-'; } var n = new String(i); var a = []; while(n.length > 3) { var nn = n.substr(n.length-3); a.unshift(nn); n = n.substr(0,n.length-3); } if (n.length > 0) { a.unshift(n); } n = a.join(delimiter); amount = minus + n; return amount; } I am calling this