jQuery,js如何扩展自定义方法

(jQuery.fn.myMethod=function () {
       alert('myMethod');
})
(function ($) {
        $.fn.extend({
             myMethod : function () {
                  alert('myMethod');
             }
        })
})(jQuery)

js String扩展方法

String.prototype.repalceA=function(){

   return this.replace(/a/g,'A')
}

'asdasdasd'.repalceA()
"AsdAsdAsd"

原文地址:https://www.cnblogs.com/lwwen/p/10412800.html