method one:
formatMoney(parseFloat(jsonArr[i].nMarketPrice)/100, 2);
function formatMoney(num,n) {?
??? if(num && n){
??? ??? num = parseFloat(num);
??? ??? num = String(num.toFixed(n));
??? ??? var re = /(-?\d+)(\d{3})/;
??? ??? while(re.test(num)) {
??? ??? ??? num=num.replace(re,"$1,$2");
??? ??? }
??? ??? return num;
??? } else {
??? ??? return "0.00";
??? }
}
method two:
缩小100倍保留N位小数(最后一位会四舍五入)
function formatMoney(num,n) {?
??? return (num*0.01).toFixed(n);
}
详细解决方案
js对钱钱币的格式化处理
热度:444 发布时间:2012-10-26 10:30:59.0
相关解决方案