function fun(){}//定义一个类(函数)
//给该类原型上添加一个方法extned
fun.prototype.extend = function(obj){
for(var a in obj)
this[a] = obj[a];//注意:这里的this即是fun.prototype
}
//调用extend方法给fun.prototype上添加属性,方法
fun.prototype.extend({name:”fun2″,method1:function(){}})
//输出name,extend,method1
console.dir(new fun())
因此扩展的属性或方法都添加到jQuery对象上了。如bind, one, unbind等可以通过$(“…”).bind, $(“…”).one, $(“…”).unbind方式调用。却不能通过 $.bind, $.one, $.unbind方式调用。
jQuery与Prototype一样都是通过extend方法扩展出整个库的。相对来说jQuery的扩展方式更难理解一些。
总结如下:
1,jQuery.extend({…})是给function jQuery添加静态属性或方法。
2,jQuery().extend({…})是给jQuery对象添加属性或方法。
/js/2011/zchain/zchain-0.2.js










