jQuery 扩展实现

来源:互联网 发布:java linklist方法 编辑:程序博客网 时间:2024/05/16 15:47
/** * Created by mr_yi on 2017/8/24. */var  a = 123;(function($){   // 为 jquery 对象设置属性   $.fn.messager = {       alert:function(msg){           alert(msg);       },       confirm:function(msg){            confirm(msg);       }   };   //为 jquery 类本事设置 静态方法   $.extend({       alert:function(msg){           alert(a);       },       messager:{           alert:function(msg,fn){               console.debug(typeof fn);               console.debug(typeof fn === 'function');               if(typeof fn === 'function'){                  fn.call();               }           }       }   });}(window.jQuery));

原创粉丝点击