图片上传不了,老出错;就只能复制啦!这个是我自己构造的对象,用console.log输出看到是这样;foo.fn.foo.init{0:div,1:div,2:div,3:div,4:div,selector:"div",init:function,aouth:"jer",age:24,add:"江西"…}jquery对象用console.log输出像一个数组;[div,div,div,div,div,prevObject:b.fn.b.init[1],context:document,selector:"div",jquery:"1.9.1",constructor:function…]想知道它是怎么实现的,下面是我写的源码;(function(){functionfoo(selector){returnnewfoo.prototype.init(selector);};foo.fn=foo.prototype={init:function(selector){varelems=document.getElementsByTagName(selector),len=elems.length,i=0;for(;ithis[i]=elems[i]; };this.selector=selectorreturnthis;},aouth:'jer',age:24,add:'江西'};foo.prototype.init.prototype=foo.prototype;foo.fn.sayName=function(){returnthis;};foo.fn.sayAdd=function(){returnthis;};window.foo=foo;})();//console.log(foo);varselects=foo('div');console.log(selects);
相关分类