为jquery添加扩展标准思路

jquery扩展分为对象扩展和jquery本身类扩展:

对象扩展:

(function($){
    $.fn.abc = function(){
        console.log($(this).get(0));
    }
})(jQuery);

使用方法:

$(function(){
    $(".otherdiv").abc();
});

jquery本身类扩展:

(function($){
    $.extend({
        showMsg:function(){
            alert('some msg');
        }
    });
})(jQuery);

使用方法:

$(function(){
    $.showMsg();
});
If the copyright belongs to the longfei, please indicate the source!!!
原文地址:https://www.cnblogs.com/longfeiPHP/p/9012996.html