zoukankan      html  css  js  c++  java
  • jquery插件的模板

    /*!
     * jQuery plugin boilerplate
     */
    ;(function ( $, window, document, undefined ) {
        
        var pluginName = "defaultPluginName", //插件名称
            defaults = { //默认设置
                propertyName: "value"
            };
    
        // 插件的构造函数
        function Plugin( element, options ) {
            this.element = element;
            this.options = $.extend( {}, defaults, options) ;
            
            this._defaults = defaults;
            this._name = pluginName;
            
            this.init();
        }
        
        //原型方法
        Plugin.prototype = {
           //初始化
           'init' : function(){
    
           }
        };
    
        //创建jquery插件
        $.fn[pluginName] = function ( options ) {
            return this.each(function () {
           var pName = "plugin_" + pluginName;
    //避免Plugin组件的重复实例化 if ( !$.data(this, pName) ) { $.data(this, pName, new Plugin(this, options) ); } }); } })( jQuery, window, document );
  • 相关阅读:
    第十二周作业
    2019春总结作业
    第一次实验总结
    第二次实验总结
    第十二周
    第十一周作业
    第九周作业
    第八周作业
    第七周作业
    第六周作业
  • 原文地址:https://www.cnblogs.com/langtao/p/3623080.html
Copyright © 2011-2022 走看看