js金额处理加小数点后两位
function toDecimal2(x) { var f = parseFloat(x); if (isNaN(f)) { return false; } var f = Math.round(x*100)/100; var s = f.toString(); var rs = s.indexOf('.'); if (rs < 0) { rs = s.length; s += '.'; } while (s.length <= rs + 2) { s += '0'; } return s; }
posted on 2018-07-09 09:39 婆婆买了只kitty 阅读(162) 评论(0) 编辑 收藏 举报