I'd like to understand the jQuery plugin syntax

前端 未结 7 996
遇见更好的自我
遇见更好的自我 2020-11-28 18:39

The jQuery site lists the basic plugin syntax for jQuery as this:

(function( $ ){    
  $.fn.myPlugin = function() {      
    // there\'s no need to do $(th         


        
相关标签:
7条回答
  • 2020-11-28 19:18

    The jQuery at the end passes itself (jQuery) over to the function, so that you can use the $ symbol within your plugin. You ccould also do

    (function(foo){
    
      foo.fn.myPlugin = function() {
    
    
        this.fadeIn('normal', function(){
    
    
        });
    
      };
    })( jQuery );
    
    0 讨论(0)
提交回复
热议问题