【问题标题】:How to format number to a currency format using String.localeFormat() using jquery?如何使用 jquery 使用 String.localeFormat() 将数字格式化为货币格式?
【发布时间】:2012-07-26 23:17:15
【问题描述】:

号码56675.456

我想用 Format 格式化这个数字:{0:$###.##}

在 JQuery 中使用 String.localeFormat()

预期结果:$56675.46

【问题讨论】:

  • String.localeFormat() 不是 jQuery / JavaScript 函数(我认为它的 .Net)
  • 您可能正在考虑 JavaScript Number.toLocaleString() 函数(请参阅 ManseUK 链接到的问题)。 jQuery 没有任何数字格式化方法(据我所知)。

标签: jquery


【解决方案1】:
function convert(num) {    
  return "$" + (num.toFixed(2));
}

convert(56675.456)

demo

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-11
    • 2014-07-20
    • 2011-06-29
    • 1970-01-01
    • 2019-02-12
    • 2020-06-21
    • 2020-07-18
    • 1970-01-01
    相关资源
    最近更新 更多