首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

jquery 源码初探,一步步兑现自己的jquery(一)

2012-10-25 
jquery 源码初探,一步步实现自己的jquery(一)最近稍微看了一下jquery的源码(1.4.2),大致上看,源码都包含在

jquery 源码初探,一步步实现自己的jquery(一)
  最近稍微看了一下jquery的源码(1.4.2),大致上看,源码都包含在下面的代码中
 

 这样的话我们就用$来代替jQuery(还是美元值钱啊)


  一般情况下,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,另外发文。



热点排行