(function($) {       
$.fn.pluginName = function() {     
     // Our plugin implementation code goes here.     
};     
})(jQuery); 上面是插件对象的代码,外层有一个这样的结构是什么意思?
(function($) {       
    
})(jQuery);

解决方案 »

  1.   

    传递jQuery做为参数,执行匿名函数.
    equal: 
    function anonymous($){...}
    anonymous(jQuery)
    好处,可以避免全局变量污染
      

  2.   

    function($) {   
        
    }
    可以理解
    那这一层外面的
    (
    )(jQuery);
    呢?
      

  3.   

    (
    )(jQuery);
    就相当于 anonymous(jQuery)
      

  4.   

    原来js中也有anonymous函数啊,我是菜鸟啊
      

  5.   

    这样写可以不?(function($) {       
    $.fn.pluginName = function() {     
         // Our plugin implementation code goes here.     
    };     
    })($);