什么版本的jquery哦。。jqeury.fn没有jquery属性吧。。jQuery.fn = jQuery.prototype = {
constructor: jQuery,
init: function( selector, context, rootjQuery ) {
var match, elem, ret, doc;
console.log(this) 输出[], init构造中 this是选择的对象集合
//....
constructor: jQuery,
init: function( selector, context, rootjQuery ) {
var match, elem, ret, doc;
console.log(this) 输出[], init构造中 this是选择的对象集合
//....
版本1.9.1
我也知道jquery.fn没有jquery属性,但是的的确确指向了这个~
jQuery.fn = jQuery.prototype = {
constructor: jQuery,
init: function( selector, context, rootjQuery ) {
var match, elem, ret, doc;
console.log( this instanceof jQuery ); // return true
console.log( this instanceof Object ); // return true
// Handle $(""), $(null), $(undefined), $(false)
版本1.9.1
我也知道jquery.fn没有jquery属性,但是的的确确指向了这个~你怎么知道this指向jquery.fn.jquery.init[0]?jQuery.fn.jquery是jquery的版本,string类型
版本1.9.1
我也知道jquery.fn没有jquery属性,但是的的确确指向了这个~你怎么知道this指向jquery.fn.jquery.init[0]?jQuery.fn.jquery是jquery的版本,string类型
你怎么知道this指向jquery.fn.jquery.init[0]?
-->Chrome单步调试看到的~
好吧 我写的时候没注意大小写,jQuery.fn.jquery是jQuery的版本不假,它显示的是jQuery.fn.jQuery.init[0]
版主大人,您别滴汗啊。。还得看您的呢,都没其他人回复我靠~~~其实我想的很简单,init是jQuery.fn的函数,那么这个this就应该指向jQuery.fn的才对。。
前面看到 new jQuery.fn.init( selector, context, rootjQuery ); 我又觉得应该就是指向init。。
本来就有点迷糊了,这个调试工具一调就更浆糊了~
原因很简单, 在fn的最后面, 有这么三行代码:
jQuery.fn = jQuery.prototype = {
// For internal use only.
// Behaves like an Array's method, not like a jQuery method.
push: core_push,
sort: [].sort,
splice: [].splice
};
jq对象本身是个Object,添加了Array的专有方法后,就变得像数组了,看上去就是Object[length],多么像数组啊!!!
嗯。。就是这么回事。
That's all.