var jQuery = function(selector) {
return new jQuery.fn.init(selector);
};
jQuery.fn = jQuery.prototype = {...};
var init = jQuery.fn.init = function(selector){
this.selector = selector;
this.element = document.querySelector(this.selector);
};
console.log(
jQuery('div').selector
);
目前,我正在學習jQuery的工作,但我有幾個問題像jQuery的風格創建庫
jQuery.fn = jQuery.prototype = {};
爲什麼prototype = object
,不是一般的原型來後用名jQuery.prototype.foo = function...
var init = jQuery.fn.init (jQuery.prototoype.init)
當我刪除var init
,我得到了一個錯誤,像這樣:var jQuery.fn.init = ...
是jQuery.fn.init = jQuery.prototype.init?這涉及到jQuery.prototype = {}對象? –