Óû§Ãû£ºdepr**edؼÌì
µ«ÓÉÓÚ¹¤×÷µÄÔÒò£¬ºÜ¾Ã²»Ôø×ö¹ýÍøÕ¾ÏîÄ¿ÁË£¬Ò²Ã»ÓÐʱ¼äÈ¥ºÃºÃÑо¿JqueryµÄÔ´Â룬Õâ¸öÒÉÎÊҲһֱûÓеõ½½â¾öÁË£¬½ñÌ죬¿ÕÏÐÖ®Ó࣬´ò¿ªJqueryµÄÔ´Âë¿´¿´£¬²ÅÃ÷ÌìËüʵÏÖµÄÔÀí£¬ÔÀ´ÔÚ¼ÓÈëjqueryµÄjsÕâ¸öÎļþʱ£¬Êµ¼ÊÉÏÊÇÖ´ÐÐÁËÒ»¸öº¯Êý£¬ÔÚÕâ¸öº¯ÊýÀZ¾³õʼ»¯ÁË$ºÍJQuery±äÁ¿,ʵÏÖÕâ¸ö¹¦ÄÜÔ´ÂëÈçÏÂ(´úÂëÒÑɾ¼õºÍ¸ü¸Ä£¬²¢²»Ó°Ïì˵Ã÷ʵÏÖÔÀí):
¸´ÖÆ´úÂë´úÓ¡µ¥¶Ï¾ÉÊÖÔ¹óÇòδǿÂëÈçÏÂ:
(function(){
var
//Willspeedupreferencestowindo²ÝÁ÷w,andallowsmungingitsname.
window=t±Êºó¸»±£Öܽïhis,
//WillspeedupreferencestoundefÅɵÀÕæÏʵ¼ÔðÑÇÔõµÛ¸»ined,andallowsmungingitsname.
undefined,
//Map³ÉÖ½»Ó»¨overjQueryincaseofoverwrite
_jQuery=windÌ«ÈÔÔõÑÎow.jQuery,
//Mapoverthe$incaseofoverwrite
_$=window.$,
jQueryºÎ¶ÎºñÃÅÊöȼ²¨ºñ¹Ì=window.jQuery=window.$=function(selector,context){
/°åÊØÉù¾°µ±/ThejQueryobjectisactuallyjusttheinitconstructor'enhanced'
returnnewjQuery.fn.init(selector,contÉ绹¾ç²ËÁô¶ûÑøÎ¯ext);
},
//Asim×÷ÑÒÕßÍâÔÓϸÂúplewaytocheckfÎ÷±£ÊÖorh**TMLstringso½ºÔÙÎÊÃñ·¢¹â×ÜÒÑÊ®rIDstrinÂÛ¼ä¸ùΰÈÔÊôgs
//(bothofwhichweoptimiz¶¼ÐÇ´¡À¨ÄÏ·âÁî²ßÆûefor)
quickExprÍ£ÉóƬʳԲ¿´=/^[^<]*(<(.|½«¶Ï°¸Ìâ\s)+>)[^>]*$|^#([\w-]+)$/,
//Isitasimpleselector
isSimple=/^.[^:#\[\.,]*$/;
jQuery.fn=jQuery.prototype={
init:function(selector,context){
//M**esurethataselectionwasprovided
//M**esu¶½¾ÉרÑÝrethataselectionwasprovided
selector=selector||document;
this[0]=selector;
this.length=1;
this.context=selector;
returnthis;
},
show:function(){
alert("***.show");
},
//Startwithanemptyselector
selector:"",
//ThecurrentversionofjQuerybeingused
jquery:"1.3.2"
};
jQuery.fn.init.prototype=jQuery.fn;
})();
functiontest(src){
alert($(src));
$(src).show();
´Ó´úÂëÀïÎÒÃÇ¿ÉÒÔ¿´µ½ÓÐÕâÑùÒ»¸öº¯ÊýÖ´ÐÐÁË(funtion(){})();
varwindow=this;
_jQuery=window.jQuery;
_$=window.$;
Õ⼸¾ä´úÂëÓ¦¸ÃÊÇÉùÃ÷jQueryºÍ$±äÁ¿£¬ÖÁÓÚΪʲôÄÜÕâÑù×ÓÓÃÎÒ»¹Ã»ÅªÃ÷°×£¬µÈ´ý¸ßÈ˽â¾ö£¡£¡
µ«ÎÒÈÏΪÕⲢû¹ØÏµ£¬ÒòΪ×îÖØÒªµÄÊÇÏÂÃæÕâ¶Î´úÂë:
jQuery=window.jQuery=window.$=function(selector,context){
returnnewjQuery.fn.init(selector,context);
};
¿ÉÒÔ¿´³ö´´½¨jQuery.fn.initÕâÑùÒ»¸öº¯Êý·µ»Ø¸ø$£¬ÕâÑùÊÇ¿ÉÒÔʹÓÃ$ʵÀýÁË£¬µ«»**»ÄÜ·ÃÎÊjQuery.fnÀïµÄ·½·¨£¬Òò´ËÐèÒª¼ÓÉϺóÃæÕâ¾ä:
jQuery.fn.init.prototype=jQuery.fn;
ʵÏÖÁËÕâЩ£¬JqueryÖÐµÄÆäËû¹¦ÄܾͺܺÃÀí½âÁË£¬ÎÞ·ÇÊÇÌíprototype»òextendÖеķ½·¨ÁË.