我从这里收到了一个代码截图: http: //jsdude.wordpress.com/2012/12/19/jquery-event-callbacks-and-javascript-oop-methods/:
var CounterButton = function(el){
this.$el = $(el);
this.counter = 0;
this.bindEvents();
this.myVal = 1;
}
CounterButton.prototype.bindEvents = function(){
this.$el.click(this.clicked);
};
CounterButton.prototype.clicked = function(){
this.increase();
this.showMessage();
};
我试图找出这条特定的线:his.$el.click(this.clicked);
. 当您this
在click
函数内部时,这是否指的是被点击的内容this.$el
?