这个也不行。有谁知道发生了什么?钛JavaScript:“那。”不起作用
编辑: qwerty简称为“qwerty();”当在其他代码段。 它应该是独立的。
编辑:我意识到什么是错的。问题出在我...
function qwerty() {
..... for loop that changes i ......
var that = this;
this.chara[i] = createlabel.....
this.chara[i].addEventListener('click', function(e) {
var j = e.source.id;
alert("hello word");
alert(this.chara[j].width); // I get the error here
});
this.chara[i].addEventListener('doubleclick', function(e) {
alert("hello word");
alert(that.chara[i].width); // I get the error here too.
});
}
什么错误,你得到?以及这个函数是如何被调用的? – ManseUK 2012-02-12 10:18:12
我定义的变量在哪里?事件绑定函数是异步的,所以我的值可能不是你所期望的。 – johnhunter 2012-02-12 10:47:51