JQuery保留金额两位小数的写法

//金额格式
            function moneyFormat(val){
                if(val == "" || val == null){
                    return "0.00";
                }
                var value=Math.round(parseFloat(val)*100)/100;
                var xsd=value.toString().split(".");
                if(xsd.length == 1){
                    value=value.toString()+".00";
                    return value;
                }
                if(xsd.length>1){
                    if(xsd[1].length<2){
                        value=value.toString()+"0";
                    }
                    return value;
                }
            }

猜你喜欢

转载自blog.csdn.net/DorAction/article/details/85166273
今日推荐