来源 <http://blog.csdn.net/tuwen/article/details/11464693>

            aClass.sayHello = function(){
                alert('say hello');
            }
        aClass.sayHello() ;//aClass的静态方法

 

定义类对象方法扩展

      aClass.prototype.protoSayHello = function(){
                alert('prototype say hello');
            }

       var aObject = new aClass();
            aObject.protoSayHello();  //类对象的方法扩展

 

JQuery的方法扩展

定义JQuery的静态方法

            jQuery.extend({
                staticHello: function () {
                    alert("wwg, staticHello");
                }
            });
          var str = $.staticHello();

 

定义JQuery对象的扩展方法

            jQuery.fn.ObjHello = function () {
                return alert("ObjHello");
            }


            $("#htmlDiv").ObjHello();

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-19
  • 2021-08-10
  • 2022-12-23
  • 2022-12-23
  • 2021-10-09
  • 2022-12-23
相关资源
相似解决方案