labihua

jquery源码笔记

2015-05-25 19:19  厘澄  阅读(125)  评论(0编辑  收藏  举报

1、jquery初始化

function jQuery() {
    return new jQuery.prototype.init();
}

jQuery.prototype.init = function () {}
jQuery.prototype.css = function () {}

为啥链式运动可以直接调用呢?
jquer().css()
是因为
jquery增加了这一句:
function jQuery() {
    return new jQuery.prototype.init();
}

jQuery.prototype.init = function () {}
jQuery.prototype.css = function () {}
jQuery.ptotype.init.prototype = jQuery.prototype;
这样init的prototype就引用了jQuery.prototype

  

分类:

技术点:

相关文章: