标签:数字货币 bsp rev == ++ spl turn mon function
//将1,234,567.00转换为1234567.00 function moneyToNumValue(val) { var num = val.trim(); var ss = num.toString(); if (ss.length == 0) { return "0"; } return ss.replace(/,/g, ""); } //调用:fmoney("12345.675910", 3),返回12,345.676 function fmoney(s, n) { n = n > 0 && n <= 20 ? n : 2; s = parseFloat((s + "").replace(/[^\d\.-]/g, "")).toFixed(n) + ""; var l = s.split(".")[0].split("").reverse(), r = s.split(".")[1]; t = ""; for (i = 0; i < l.length; i++) { t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? "," : ""); } return t.split("").reverse().join("") + "." + r; }
标签:数字货币 bsp rev == ++ spl turn mon function
原文地址:https://www.cnblogs.com/qhorse/p/8965605.html