高人指点 看jquery源码的一些基础问题
时间:2011-09-06
来源:互联网
希望有高人指点,里头的this分别指向谁,为什么结果是罗列出来的那些。。????????
var $=jQuery=function(){
return new jQuery.fn.init();//返回原型方法init();
}
jQuery.fn=jQuery.prototype={
init:function(){//在初始化原型方法中返回实例的引用
this.length=0;
this.test=function(){
return this.length;
};
return this;
},
jQuery:"1.3.2",
length:1,
size:function(){
return this.length;
}
};
alert($().jQuery);//返回undefined
alert($().test());//返回0
alert($().size());//抛出异常
var $=jQuery=function(){
return new jQuery.fn.init();//返回原型方法init();
}
jQuery.fn=jQuery.prototype={
init:function(){//在初始化原型方法中返回实例的引用
this.length=0;
this.test=function(){
return this.length;
};
return this;
},
jQuery:"1.3.2",
length:1,
size:function(){
return this.length;
}
};
alert($().jQuery);//返回undefined
alert($().test());//返回0
alert($().size());//抛出异常
作者: cutemurphy 发布时间: 2011-09-06
$()返回的对象包括的JQ中的属性有:
{
length: 0,
test: function(){return this.length;}
}
$().JQuery,你看下上门的属性,有这个吗? 当然是undefined
$().test(); 调用test函数,返回length, 属性看看,是0对吗
alert($().size()): 属性中有size属性吗? 没有吧,你还把它作为一个方法调用,当然抛出函数异常。
{
length: 0,
test: function(){return this.length;}
}
$().JQuery,你看下上门的属性,有这个吗? 当然是undefined
$().test(); 调用test函数,返回length, 属性看看,是0对吗
alert($().size()): 属性中有size属性吗? 没有吧,你还把它作为一个方法调用,当然抛出函数异常。
作者: dxx1988 发布时间: 2011-09-06
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28