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

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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"

 


以上是关于jQuery,js如何扩展自定义方法的主要内容,如果未能解决你的问题,请参考以下文章