我有一个脚本(似乎)在 for 循环结束时随机停止。它完成了每次迭代,并且完成了每次迭代中的所有内容,但随后它神秘地停止了。如您所见,“继续前进”警报永远不会触发。任何帮助表示赞赏!
代码:
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/