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
  • 相关阅读:
    学生管理系统后感
    数据库是什么鬼,怎么连接,怎么搞
    nIce 不看会后悔的o!
    那些年披巾斩浪的数据库
    day82
    day81
    day80
    day79
    day78
    day77
  • 原文地址:https://www.cnblogs.com/zhaowei303/p/4989175.html
Copyright © 2011-2022 走看看