这是在超时函数中循环。 nw保持未定义状态,或者在每次新的启动时重新设置为undefined。这是为什么?在Javascript中组装var var
$("#wert"+i).load('variable.html #w'+i);
if(! nw){
alert(nw);
var nw = eval('neuerwert'+i); // Here I set the var nw, so why is it undefined again the next time around?
}
if ($("#w"+i).html() != nw){
wertaenderung('#wert'+i);
nw = $("#w"+i).html();
};
您需要将变量声明放在函数之外,以便它继续存在。 – Barmar
这是一个答案(确实是正确的答案),不仅仅是评论。 – Utkanos
应该不是所有的代码都在'.load'触发的回调函数中吗? – Alnitak