尝试在click事件中获取对象。我在这做错了什么? this.section是每个按钮的索引。
this.ebutton = jQuery('.episode_button');
this.button = this.ebutton.eq(this.section);
this.listtext = 'testbutton';
this.button.parobj = this;
this.button.bind('click', function() {
alert(this.parobj.listtext());
});
如何在按钮事件中获取属性listtext?
答案 0 :(得分:0)
答案 1 :(得分:0)
var epi = {};
/*Startpage*/
epi.start = {
epilist: [],
init: function () {
this.ebutton = jQuery('.episode_button');
this.episodelist.prototype = this;
this.epilist.push(new this.episodelist(0));
},
episodelist: function (index) {
this.name = 'test'
this.button = this.ebutton.eq(index);
this.button.parobj = this;
this.button.bind('click', function() {this.parobj.episodelistshow();});
},
episodelistshow: function () {
// This will not alert correctly!
// Should alert test
alert(this.name);
}
}