zoukankan      html  css  js  c++  java
  • JS,JQuery的扩展方法

    转 http://blog.csdn.net/tuwen/article/details/11464693 

    //JS的扩展方法: 1 定义类静态方法扩展 2 定义类对象方法扩展
                var aClass = function(){}


                //1 定义这个类的静态方法
                aClass.sayHello = function(){
                    alert('say hello');
                }


                //2 定义这个类对象的对象方法
                aClass.prototype.protoSayHello = function(){
                    alert('prototype say hello');
                }




                aClass.sayHello() ;//aClass的静态方法


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


                //JQuery的方法扩展


                //定义jquery的扩展方法
                //1 定义JQuery的静态方法
                jQuery.extend({
                    staticHello: function () {
                        alert("wwg, staticHello");
                    }
                });


                var str = $.staticHello();


                //2 定义JQuery对象的扩展方法
                jQuery.fn.ObjHello = function () {
                    return alert("ObjHello");
                }


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

    开源代码

     www.codeplex.com
    www.codeproject.com 
    github
  • 相关阅读:
    继承
    类和对象
    Scanner类
    面向对象思想
    final关键字
    The difference between text mode and binary mode with file streams
    Linux下常见权限操作相关命令
    Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext
    手动运行jar包,指定配置文件
    jdk 1.8.0_131 Class JavaLaunchHelper is implemented
  • 原文地址:https://www.cnblogs.com/zhaowei303/p/4989175.html
Copyright © 2011-2022 走看看