码迷,mamicode.com
首页 > Web开发 > 详细

为jquery添加扩展标准思路

时间:2018-05-09 12:10:11      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:cti   ons   col   some   this   扩展   end   console   color   

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();
});

 

为jquery添加扩展标准思路

标签:cti   ons   col   some   this   扩展   end   console   color   

原文地址:https://www.cnblogs.com/longfeiPHP/p/9012996.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!