JS添加千分位与去掉千分位的示例_javascript技巧
时间:2021-07-01 10:21:17
帮助过:5人阅读
代码如下:
function commafyback(num)
{
var x = num.split(',');
return parseFloat(x.join(""));
}
function commafy(num)
{
num = num.toFixed(2) +"";
var re=/(-?/d+)(/d{3})/
while(re.test(num)){
num=num.replace(re,"$1,$2");
}
return num;
}