相当于PHP函数number_format的JS是什么? [英] What is the JS equivalent to the PHP function number_format?

查看:48
本文介绍了相当于PHP函数number_format的JS是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PHP函数:

function formatNumberForDisplay($number, $decimal=0, $decimalSeperator='.', $numberSeperator=',')
{
     return number_format($number, $decimal, $decimalSeperator, $numberSeperator);
}

有人可以向我建议jQuery/JavaScript中的等效功能吗?

Can anybody suggest to me the equivalent functionality in jQuery/JavaScript?

推荐答案

这是您想要的吗?

yourFloatVarHere.toFixed(2);

瞧瞧.

这篇关于相当于PHP函数number_format的JS是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆