js數字轉換成財務金額
阿新 • • 發佈:2018-10-18
div 數字 bst value indexof oat spa pan func
function dealNumberToMoney(money){ var fmtAmt = ""; if(money&&money!=null){ money = money.replace(/,/g,"").replace(/,/g,""); if(money.indexOf(".")==-1){ money = money + ".00"; } var index = money.indexOf("."); var floatValue = money.substring(index+1);var count = 0; for(var i=(index);i>=0;i--){ fmtAmt = money[i]+fmtAmt; if(count==3&&i!=0){ fmtAmt = "," + fmtAmt; count = 0; } count++; } } fmtAmt += floatValue;return fmtAmt; }
js數字轉換成財務金額