//插件编写模板;(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