[JavaScript] jquery插件模板 →→→→→进入此内容的聊天室

来自 , 2019-12-07, 写在 JavaScript, 查看 108 次.
URL http://www.code666.cn/view/22cdb13a
  1. (function($){
  2.     $.yourPluginName = function(el, radius, options){
  3.         // To avoid scope issues, use 'base' instead of 'this'
  4.         // to reference this class from internal events and functions.
  5.         var base = this;
  6.        
  7.         // Access to jQuery and DOM versions of element
  8.         base.$el = $(el);
  9.         base.el = el;
  10.        
  11.         // Add a reverse reference to the DOM object
  12.         base.$el.data("yourPluginName", base);
  13.        
  14.         base.init = function(){
  15.             if( typeof( radius ) === "undefined" || radius === null ) radius = "20px";
  16.            
  17.             base.radius = radius;
  18.            
  19.             base.options = $.extend({},$.yourPluginName.defaultOptions, options);
  20.            
  21.             // Put your initialization code here
  22.         };
  23.        
  24.         // Sample Function, Uncomment to use
  25.         // base.functionName = function(paramaters){
  26.         //
  27.         // };
  28.        
  29.         // Run initializer
  30.         base.init();
  31.     };
  32.    
  33.     $.yourPluginName.defaultOptions = {
  34.         radius: "20px"
  35.     };
  36.    
  37.     $.fn.yourPluginName = function(radius, options){
  38.         return this.each(function(){
  39.             (new $.yourPluginName(this, radius, options));
  40.  
  41.                    // HAVE YOUR PLUGIN DO STUFF HERE
  42.                        
  43.        
  44.                    // END DOING STUFF
  45.  
  46.         });
  47.     };
  48.    
  49. })(jQuery);
  50.  
  51.  
  52. //javascript/4275

回复 "jquery插件模板"

这儿你可以回复上面这条便签

captcha