Tag: 子类

jquery如何返回所选元素的数组

我刚刚看到John Resig提出的谷歌技术讲座,他说jQuery作为一个arrays运行。 按照这个建议,我一直在玩一个子类arrays,它工作得很好但是我一直在查看jQuery源代码并且看不到他们使用了相同的方法 jQuery.prototype = new Array(); 我甚至无法看到它使用调用/ apply的原生Array.prototype.methods或窗口中的原型链。$ object,所以我想知道jQuery对象如何返回所选元素的数组。 我尝试过使用普通对象,但是如果返回一个数组就会停止链接命令的能力 如果可以从Array.prototype中获取一些返回数组的必要方法? 这就是我正在玩的东西。 ;(function(window, document, undefined){ function MyLib(){}; // prototype constructor functions function Core(){}; function Methods(){}; // create new instance of the MyLib object and call the construct method function myLib(selector){ return new MyLib().construct(selector); } // allow adding new methods to the prototype from the […]