首页 > Web开发 > 详细

jquery 插件封装模板

时间:2018-01-23 12:42:44      阅读:216      评论:0      收藏:0      [点我收藏+]
//插件编写模板
;(function ($) {
    $.fn.plugIn = function ( opt ) {
        var def = {
            //这里填写自定义的参数例如:
            event : ‘click‘
        }
        opt = $.extend( def , opt );
        this.each(function(){

            var that = $(this); //that 指的是 .box
             //测试执行
            that.on( opt.event , function(){
                alert( opt.event );
            });

        });
        return this;
    }
})(jQuery);

//调用
$(‘.box‘).plugIn({
    event : ‘mouseover‘ //可进行篡改
});

  

jquery 插件封装模板

原文:https://www.cnblogs.com/zhoubingyan/p/8335018.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!