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

    https://www.cnblogs.com/st-leslie/p/5154276.html

     我的demo

    <body>
        <div class="default">默认的样式</div>
        <div class="default">默认的样式</div>
        <div class="default">默认的样式</div>
        <div class="change">修改后的样式</div>
    </body>
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript" src="old.js"></script>
    <script type="text/javascript">
    $(function(){
        var opt = {
            'font-size':"20px"
        }
        $(".default").highLight(opt);
        var t = $(".default").showOptions();
        console.log(t);
    })
    </script>
    (function ($) {
        var defaults = {
            foreground: 'red',
            background: 'yellow'
        }
        var cal = null;
        var Cal=function(ele,opt){
            this.element=ele;
            this.options=$.extend({},defaults,opt);
        }
        //定义对象的方法
        Cal.prototype = {
            init:function() {
                var that = this.options;
                this.element.each(function () {  
                    $(this).css({
                        backgroundColor: that.background,
                        color: that.foreground
                    });
                });
             },
             getDate:function(){
                return this.options
             }
        };
        $.fn.extend({
            "highLight": function (options) {
                cal=new Cal(this,options);
                cal.init();
            },
            "showOptions":function(){
                console.log(cal.options)
                return cal.getDate();
            }
        });
        
    })(jQuery);
  • 相关阅读:
    数学考试
    奇♂妙拆分
    11.25
    11.21
    11.20
    11.19
    11.18
    11.15
    11.14作业
    11.14
  • 原文地址:https://www.cnblogs.com/beimingbingpo/p/9714494.html
Copyright © 2011-2022 走看看