try {
(1).toFixed(1);
}
catch(e) {
Number.prototype.toFixed = function(dot) {
with(Math){
var m=pow(10,Number(dot))
var s = (round(this*m)/m).toString();
}
if(s.indexOf('.') < 0)
s += ".";
s += "00000000000000000000000000";
return s.substr(0,s.indexOf('.')+dot+1);
}
}
alert((133.996).toFixed(2));
(1).toFixed(1);
}
catch(e) {
Number.prototype.toFixed = function(dot) {
with(Math){
var m=pow(10,Number(dot))
var s = (round(this*m)/m).toString();
}
if(s.indexOf('.') < 0)
s += ".";
s += "00000000000000000000000000";
return s.substr(0,s.indexOf('.')+dot+1);
}
}
alert((133.996).toFixed(2));
解决方案 »
- 怎么让这个鼠标移动上去的时候延迟2秒才促发animate呢
- updateCnt=0; 是什么意思
- 请问哪个版本的jquery兼容性最好啊?
- 请教js 获取session中对象的问题。
- 如何点击div中的任意节点后,显示出从该节点到最顶端节点的每一个ID?
- ◆◆这样的赋值语句是什么意思?re = /\[|\]/; ◆◆
- 如何使用javascript实现站内搜索?
- “类不能支持automation操作”是什么错误?
- 弹出窗口问题
- 管理员请进!为什么http://expert.csdn.net/Expert/topic/1917/1917941.xml?temp=.869198不能回复呢??
- 如何调用本地已注册dll文件???
- 一个用光标控制的问题
alert(Math.round(100.99*10)/10); //保留一位小数点
alert(Math.round(100.99*100)/100); //保留两位小数点
Param: amount 数值
peci 小数位数
*/
function formatNumber(amount , peci){
var result = new Number(amount);
var pecision = 2 ;
if(peci != null) pecision = peci ;
return result.toFixed(pecision) ;
}