jquery 源码初探,一步步实现自己的jquery(一)
最近稍微看了一下jquery的源码(1.4.2),大致上看,源码都包含在下面的代码中
一般情况下,js创建类也需要定义属性和方法(可以不定义),创建模式如下:
jQuery.fn = jQuery.prototype={ // Start with an empty selectorselector: "",// The current version of jQuery being usedjquery: "1.4.2",// The default length of a jQuery object is 0length: 0,// The number of elements contained in the matched element setsize: function() {return this.length;},toArray: function() {return slice.call( this, 0 );},…… }以上是一些基本的简单的介绍,下篇开始实现自己的jquery。对于扩展jQuery,另外发文。