首页 > Web开发 > 详细

jQuery源码解读三选择器

时间:2017-03-23 12:34:50      阅读:199      评论:0      收藏:0      [点我收藏+]

直接上jQuery源码截取代码

// Map over jQuery in case of overwrite
_jQuery = window.jQuery,

// Map over the $ in case of overwrite
_$ = window.$,

// Define a local copy of jQuery 可以看出创建了jQuery.fn.init这样的一个函数返回给$,这样就可以使用$实例了
jQuery = function (selector, context) {
// The jQuery object is actually just the init constructor ‘enhanced‘
return new jQuery.fn.init(selector, context, rootjQuery);
},

//下面的这两句,使得$实例可以访问jQuery.fn里面的方法
jQuery.fn = jQuery.prototype = {

init: function (selector, context, rootjQuery) {

},
}

// Give the init function the jQuery prototype for later instantiation
jQuery.fn.init.prototype = jQuery.fn;

 

jQuery源码解读三选择器

原文:http://www.cnblogs.com/zouyanzhi/p/6594407.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!