/**
* 金额格式化
* 例子:fmoney("12345.675910", 3),返回12,345.676
* @data 备注lhh 2016-09-18
*/
function fmoney(s, n) { if (n == 0) { s = parseFloat((s + "").replace(/[^d.-]/g, "")) + ""; var l = s.split(".")[0].split("").reverse(), t = ""; for (i = 0; i < l.length; i++) { t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? "," : ""); } return t.split("").reverse().join(""); } 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; }