所以,我沒有看到爲什麼這不起作用的原因,但我在牆上和沮喪。爲什麼我不能在wyr.message.close函數中調用this.myself?也許我對此的理解是可以理解的,但我確信這是指對象本身,而不是功能。JS對象,如何從我自己內部訪問對象
this.myself is undefined
代碼:
wyr.message = {
myself: $('.message'),
init: function() {
if(this.myself.is(':visible')){
setTimeout(this.close, 5000);
}
},
close: function(){
this.myself.fadeOut(1200,function(){
this.myself.remove();
});
}
}
您可以添加一個使用示例嗎?目前還不完全清楚你想用'message'來做什麼,並且可能有一種更習慣的方式來實現你的目標。 – 2012-02-13 15:46:59