//定义一个自执行函数并且返回一个jQ对象 (function(window){ //alert("测试"); var jQuery=function(){ //使用init返回jQ对象 return jQuery.prototype.init(); }; jQuery.prototype.init=function(){ //修正原型指向 var toString={}.toString, length=0; constructor:jQuery; return this; }; var $=jQuery; jQuery.fn=jQuery.prototype; jQuery.fn=jQuery.prototype.init.prototype; //使返回的对象在window全局下 window.$=window.jQuery=jQuery; })(window); console.info($());