js保留两位小数四舍五入:
(Math.floor(until_price*100)/100).toFixed(2);//会四舍五入
保留两位小数 且不四舍五入(三种方式,请用最后一种):
var num="2.999999999";
num = Number(num);
num*=100;
num = (Math.floor(num)/100).toFixed(2);
alert(num);
var a = "2.999999999";
a = a-0;
a*=100;
a = (Math.floor(a)/100).toFixed(2);
alert(a);
var s = "2.019";
s = s-0 +.00000000000001;
s*=100;
s=(Math.floor(s)/100).toFixed(2);
alert(s);//弹出:2.01;
阿拉伯数字转换汉字js方法:
function convertToChinese(num){
var N = [
"零", "一", "二", "三", "四", "五", "六", "七", "八", "九"
];
debugger;
var str = num.toString();
var len = num.toString().length;
var C_Num = [];
for(var i = 0; i < len; i++){
C_Num.push(N[str.charAt(i)]);
}
return C_Num.join('');
}
var chinseNum = convertToChinese(3);//输出“三”;