[英]jQuery float values like php number_format(number, 2 )
I need floating number output exactly like number_format function in php. 我需要与php中的number_format函数完全一样的浮点数输出。
Javascript Code JavaScript代码
Math.round(totalCredit).toFixed(2)
PHP Code PHP代码
echo number_format(22212 , 2);
above code return me 22,212.00
and this is exactly I want in js. 上面的代码返回我
22,212.00
,这正是我想要的js。
Expected output 预期产量
22.212
22.212
Here is a good solution: 这是一个很好的解决方案:
http://locutus.io/php/strings/number_format/ http://locutus.io/php/strings/number_format/
Please, stop thinking, jQuery is made for solving any of your JS problems.
请停止思考,jQuery是为解决您的任何JS问题而设计的。 This problem is not jQuery related, jQuery is mostly (not only) for DOM related stuff
这个问题与jQuery不相关,jQuery主要是(不仅是)与DOM相关的东西
. 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.