zoukankan      html  css  js  c++  java
  • jquery插件开发

    ;(function($, window, document,undefined) {
        var Beautifier = function(ele, opt) {                      //创建对象
            this.$element = ele,                                   //接受jq对象
                this.defaults = {                                  //默认参数
                    'color': 'red',
                    'fontSize': '12px',
                    'textDecoration': 'none'
                },
                this.options = $.extend({}, this.defaults, opt)  //传递的参数和默认参数合并
        }
        Beautifier.prototype = {                                 //对象添加方法
            beautify: function() {
                return this.$element.css({
                    'color': this.options.color,
                    'fontSize': this.options.fontSize,
                    'textDecoration': this.options.textDecoration
                });
            }
        }
    
        $.fn.myPlugin = function(options) {                      //把对象的方法添加到jquery方法中
    
            var beautifier = new Beautifier(this, options);      //外部传进jq对象和用户配置
    
            return beautifier.beautify();                        //调用对象方法
        }
    })(jQuery, window, document);
  • 相关阅读:
    hh
    SDUT 3923 打字
    最短路
    阶乘后面0的个数(51Nod 1003)
    大数加法
    Biorhythms(中国剩余定理)
    usaco-5.1-theme-passed
    usaco-5.1-starry-passed
    usaco-5.1-fc-passed
    usaco-4.4-frameup-passed
  • 原文地址:https://www.cnblogs.com/yexiangwang/p/5089285.html
Copyright © 2011-2022 走看看