• Jquery插件


     (function ($, window) {
                //设置默认值并用逗号隔开
                var defaults = {
                    padding: 20,
                    mouseOverColor: '#000000',
                    mouseOutColor: '#ffffff'
                };
    
                function PaddingList(ele, options) {
                    this.ele = ele;
                    this.options = options;
                }
                PaddingList.prototype = {
                    constructor: PaddingList,
                    init: function () {
                        this.bindEvent();
                    },
                    bindEvent: function () {
                        var that = this;
                        console.log(that);
                        console.log(this.ele);
                        this.ele.find('a').hover(function () {
                            $(this).css("color", that.hoverColor);
                            //queue false表示不添加到动画队列中
                            $(this).animate({ paddingLeft: that.animatePadding }, { queue: false, duration: 300 });
    
                        }, function () {
                            $(this).css("color", "");
                            $(this).animate({ paddingLeft: "0" }, { queue: true, duration: 300 });
                        });;
                    }
                }
                //插件开始
                $.fn.paddingList = function (options) {
                    //组合参数
                    var options = $.extend(defaults, options);
                    return new PaddingList($(this), options);
                }
            })(jQuery, window)
        </script>
        <script type="text/javascript">
            $(function () {
                $("#catagory").paddingList({ animatePadding: 30, hoverColor: "Red" }).init();
            });
        </script>
    

      

  • 相关阅读:
    KVM 重命名虚机
    甲醛了解
    递归函数,匿名函数
    函数
    zabbix监控URL
    zabbix自动发现
    vim常用命令总结
    saltstack常用命令
    zabbix监控Apache
    nginx配置详解
  • 原文地址:https://www.cnblogs.com/alphafly/p/5256360.html
Copyright © 2020-2023  润新知