jquery 插件模版

;(function ($) {
        //插件的默认值属性
        var defaults = {
            Weight: '300px',
            height: '230px',
            nextId: 'nextBtn',
            nextText: 'Next'
        };
        //插件的扩展方法名称
        $.fn.easySlider = function (options) {
            // 合并用户自定义属性,默认属性
            var options = $.extend(defaults, options);
            
            $(this).click(function(){
                alert(options.Weight)
            })
        }
    })(jQuery);

    $(function(){
        //调用你的自定义插件
        $(".box").easySlider({ 
            Weight : "1px",    //调用自己定义——属性值
        }); 
    });
人如代码,规矩灵活;代码如诗,字句精伦。
原文地址:https://www.cnblogs.com/xinlinux/p/4316455.html