jquery 插件封装模板
//插件编写模板
;(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' //可进行篡改
});

浙公网安备 33010602011771号