行!首先,这个问题来自一个在jQuery世界中挖掘得太深(并且可能会迷路)的人。价值,原型和财产的区别
在我的可测量类,我发现了jQuery的主要模式是这样的(如果需要修正wellcomed):
(function (window, undefined) {
jQuery = function (arg) {
// The jQuery object is actually just the init constructor 'enhanced'
return new jQuery.fn.init(arg);
},
jQuery.fn = jQuery.prototype = {
constructor: jQuery,
init: function (selector, context, rootjQuery) {
// get the selected DOM el.
// and returns an array
},
method: function() {
doSomeThing();
return this;
},
method2: function() {
doSomeThing();
return this;,
method3: function() {
doSomeThing();
return this;
};
jQuery.fn.init.prototype = jQuery.fn;
jQuery.extend = jQuery.fn.extend = function() {
//defines the extend method
};
// extends the jQuery function and adds some static methods
jQuery.extend({
method: function() {}
})
})
当$
启动jQuery.prototype.init
启动并返回元素的数组。但我不明白它是如何增加像.css
或.hide
等jQuery方法。到这个数组。
我得到了静态方法。但无法得到它如何返回以及所有这些方法的元素数组。
@adnan thanx的编辑 – Lupus