OK! Prima di tutto questa domanda viene da un uomo che scava troppo in profondità (e si può eventualmente perdere) nell'universo jQuery.Differenza del valore, prototipo e proprietà
Nel mio Reserch ho scoperto modello principale del jquery è qualcosa di simile (Se la correzione necessaria è 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() {}
})
})
Quando $
avvia la jQuery.prototype.init
iniziati e restituisce un array di elementi. Ma non riuscivo a capire come aggiunge il metodo jQuery come .css
o .hide
, ecc. a questo array.
Ottengo i metodi statici. Ma non è possibile ottenere come restituisce e matrice di elementi con tutti quei metodi.
thanx @adnan per la modifica – Lupus