$("p").append("test").fadeIn("fast"); |
append: function() { return this.domManip(arguments, true, function(elem){ if (this.nodeType == 1) this.appendChild( elem ); }); } |
function Dog(name,color){ this.name=name||""; this.color=color||""; } Dog.prototype.setName=function(name){ this.name=name; return this; }; Dog.prototype.setColor(color){ this.color=color; return this; }; Dog.prototype.yelp(){ alert("我的名字叫:"+this.name+",我的颜色是:"+this.color); return this; }; |
var dog = new Dog(); dog.setName("旺财").setColor("白色").yelp(); |
Dog.prototype.getName(callback){ callback.call(this,this.name); return this; } |
function showName(name){ alert(name); } dog.setName("旺财").getName(showName).setColor("白色"); |