我有一个脚本(貌似)在for循环结束时随机停止。它完成每次迭代,并在每次迭代中完成所有内容,但随后它会神秘地停止。正如你所看到的,"继续前进"警报从不开火。感谢任何帮助!
CODE:
var sliderDirectionRaw = "top-left,left";
var sliderDirection = sliderDirectionRaw.split(",");
for (i=0;i<=sliderDirection.length;i++) {
if (sliderDirection[i].indexOf("-") >= 0) {
sliderDirection[i] = sliderDirection[i].split("-");
alert("Multiple directions specified in iteration "+i);
}
alert("Direction iteration "+i+" finished");
if (i == sliderDirection.length-1) {
alert("Direction loop finished");
}
}
alert("Moving on from Direction loop");
的jsfiddle: http://jsfiddle.net/k7cSE/1/
答案 0 :(得分:2)
使用“&lt;”在你的for循环而不是“&lt; =”修复你的问题......