我不知道为什么,但这段代码不工作?为什么不呢?我想这是因为我在这里有范围问题:SetTimeOut的范围问题
function washAway(obj) {
alert($(obj)); // says HTML Object which is fine
setTimeout(function() {
alert($(obj)); // says undefined
$(obj).fadeOut("slow", function() {
$(this).remove();
});
}, 2000);
};
它的工作对我来说.. – Nakul 2010-01-09 09:46:32
@Nakul:因为你的'obj'是全球性的,在此期间不会改变,与Aaron的相反。 – Tomalak 2010-01-09 09:52:07