相当于Number.prototype.toString = function(Digits) {
var val = Math.round(this * Math.pow(10, Digits)) /
Math.pow(10, Digits);
var retStr = val.toString();
var pos = retStr.indexOf('.');
if (pos < 0) pos = retStr.length;
var digits = Digits - retStr.substr(pos + 1).length;
if (digits > 0) {
if (digits == Digits) retStr += '.';
for (i = 0; i < digits; i++) retStr += '0';
}
return retStr;
}
意思是给Number的原形对象添加一个toString方法
Number对象本身已经有toString方法,所以会有这个来覆盖原有的.
var val = Math.round(this * Math.pow(10, Digits)) /
Math.pow(10, Digits);
var retStr = val.toString();
var pos = retStr.indexOf('.');
if (pos < 0) pos = retStr.length;
var digits = Digits - retStr.substr(pos + 1).length;
if (digits > 0) {
if (digits == Digits) retStr += '.';
for (i = 0; i < digits; i++) retStr += '0';
}
return retStr;
}
意思是给Number的原形对象添加一个toString方法
Number对象本身已经有toString方法,所以会有这个来覆盖原有的.
解决方案 »
- 怎么让两个函数都在页面打开时就执行
- 全选以后点下一页,返回以后全选状态不变
- qq登录协议又改了,哪位朋友有http分析工具的帮忙提取一下主要的js代码
- 请高手帮忙,小弟是菜鸟。js中如何调用php的函数,详情请进
- javascript要第二大的數....
- DW 做ASP错误 HTTP 错误 500.100 在线等
- 紧急求助:如何给window增加一个子对象????
- 怎样能对输入的ip地址进行校验,确认是否是有效的ip地址
- 誰能帮我看一下,checkbox选中时取同一行中的select,edit中的值
- 在文本框的名字命名为纯数字时,如何在javascript中操作此文本框
- 也许是我白痴,为什么这句话怎么就会出现缺少“;”的错误呢?
- 请问用JS如何显示图片?
prototype属性
js里边的仔细研究
防止重叠的元素的事件被逐级上传,如果下面的代码不使用event.cancelBubble=true;则document.onclick也能感知到鼠标点击事件
<script language="javascript">
function document.onclick()
{
alert("document感知到的");
}
function clickMe()
{
alert("按钮感知到的");
event.cancelBubble = true;
}
</script>
<input type="button" value="click me" onclick="clickMe()">
<xmp>
<font color="#0000FF">姓名:</font><input type="text" name="textbox1" size="24">
</xmp>
在IE上执行的时候,不对xmp之间的内容做解析,直接当作字符显示出来,会看到
如果在首尾加上控制,还能把这些内容变成红颜色
<font color=red>
<xmp>
<font color="#0000FF">姓名:</font><input type="text" name="textbox1" size="24">
</xmp>
</font>
直接赋值成多维数组
<script>
var s=["你好",["中国","太原","邢志云"],[3,3333],[4,4444],[5,5555],["0",["a","b","c"]],"cc"];
// 0 1 2 3 4 5 6
// 10 11 12 20 21 30 31 40 41alert(s);//你好,中国,太原,邢志云,3,3333,4,4444,5,5555
alert(s[1]);//中国,太原,邢志云
alert(s[1][2]);//邢志云
alert(s[2][0]);//3
alert(s[2][1]);//3333
alert(s[5][1][0]);//a
alert(s[5][1][2]);//c
alert(s[6]);//cc
</script>
表示定义一个对象实例.
理解这句就理解全部了.
for (property in source) {
destination[property] = source[property];
}
return destination;
}你会对"zhaoxiaoyang(梅雪香@深圳)" 的解释有更深入的理解。