我有这个 for 循环,它似乎重复第一个循环两次 (x=0),然后不执行最后一个循环 (x=2)
for (x=0;x<=2;x++)
{
if (document.getElementById("sub"+catCount+x).value != "")
{
if (nonums.test(document.getElementById("sub"+catCount+x).value))
{
total = total + parseFloat(document.getElementById("sub"+catCount+x).value);
}
}
alert(x);
}
换句话说,我收到两个带有“0”的警报框,然后是一个带有“1”的警报框,仅此而已。
谁能告诉我我在这里没有看到什么?为什么它不正常地通过循环(0,1,2)?
最佳答案
that is literally the only spot I use the variable x on any page.
for (x=0;x<=2;x++)
{
alert(x);
}
您可以在控制台测试它。
关于javascript - For 循环重复第一个循环两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3121670/