我尝试下面的代码,但不起作用触发一个错误:创建功能正常数字格式?
val.reverse is not a function
我怎样才能解决呢?
//I want this output: 1,455,000
function num(val){
var result = val.reverse().join("")
.match(/[0-9]{1,3}/g).join(",")
.match(/./g).reverse().join("");
return result
}
alert(num('1455000'))
可能重复(http://stackoverflow.com/questions/4942103/comma-formated-numbers-in-jquery) – 2011-12-29 18:23:20