jQuery的$.fn与$.extend使用结合
(function($){
$.fn.aomi_qtip = function(style='aomi_qtip_init') { //默认会运行对象aomi_extend的aomi_qtip_init方法
var aomi_extend=$.extend({
aomi_qtip_init:function(ele){
console.log(ele,11)
},
aomi_qtip_class:function(ele,that){
console.log("show",that);
},
aomi_qtip_style:function(ele){
console.log(ele)
}
});
return this.each(function() {
var that=$(this);
if(aomi_extend.hasOwnProperty(style)){ //判断aomi_qtip_init对象是否含有style方法,如果有,则运行
aomi_extend[style](33,that);
}
});
}
$("body").aomi_qtip();
$(".alert-close").aomi_qtip("aomi_qtip_class");
})(jQuery);