Turn http://blog.csdn.net/tuwen/article/details/11464693
JS extension Method: 1 Define class static method extension 2 Define Class object method extension
var aclass = function () {}
1 defining static methods for this class
Aclass.sayhello = function () {
Alert (' Say hello ');
}
2 Defining object methods for this class object
AClass.prototype.protoSayHello = function () {
Alert (' prototype say hello ');
}
Aclass.sayhello (); static method of//aclass
var aobject = new AClass ();
Aobject.protosayhello (); Method extensions for Class objects
Method Extensions for jquery
Defining extension methods for jquery
1 static methods for defining jquery
Jquery.extend ({
Statichello:function () {
Alert ("WWG, Statichello");
}
});
var str = $.statichello ();
2 Defining extension methods for jquery objects
JQuery.fn.ObjHello = function () {
Return alert ("Objhello");
}
$ ("#htmlDiv"). Objhello ();
Extension methods for Js,jquery