復制代碼 代碼如下:
 
(function (window, undefined) { 
// ... 
})(window); 
復制代碼 代碼如下:
 
(function ($) { 
// $("...")... 照常使用$ 
})(jQuery); 
復制代碼 代碼如下:
 
var jQuery = (function() { 
var jQuery = function(selector, context) { 
// 真正的初始化函數 
return new jQuery.fn.init(selector, context, rootjQuery); 
}, 
// 一大堆變量聲明 
// fn是主要的函數實現點,也是jQuery插件的起點。實際上就是JS原型 
jQuery.fn = jQuery.prototype = { 
}; 
// 一個擴展對象用的函數,可以動態地往對象上加成員。以后往jQuery里面加成員都是用extend函數完成的。 
jQuery.extend = jQuery.fn.extend = function() { 
}; 
// ... 
return jQuery; 
})(); 
新聞熱點
疑難解答