function B(sName) {
this.name = sName;
}
B.prototype = {
instanceCreatButtonCount: 0,funA: function () { // alert instance's name
alert(this.name);
},funB: function () { // create a button which clikced can alert this instance's name through funA;
var that = this;
B.prototype.instanceCreatButtonCount++;
var id = "_id" + that.instanceCreatButtonCount;
var str = "
>点击divB1后,我通过b1.funB()创建一个按钮.
>点击divB2后,我通过b2.funB()创建一个按钮.
最佳答案