function Z(params) {
for (var j in params) {
this[j] = params[j];
}
}
Z.prototype = {
show: function () {
var _this = this;
$(window).bind('resize', this.adjust); // Return undefined? Why?
//$(window).bind('resize',function(){
// _this.adjust(); // This works.
//});
},
adjust: function () {
alert(this.id);
}
}
var a = new Z({
id: 5
});
a.show();
你好,为什么this.adjust返回undefined?但是它在使用匿名函数时起作用。