我正在尝试在html页面中进行动画文本输出。但是在我的javascript代码中,即使逻辑超出条件,IF语句也不会停止。
var wss_i = 0;
var wss_array = ["Programmer", "Developer", "Brother"];
var wss_elem;
function wssNext() {
wss_i++;
wss_elem.style.opacity = 0;
if (wss_i > (wss_array.length - 1)) {
wss_1 = 0;
}
console.log(wss_i);
setTimeout('wssSlide()', 1000);
}
function wssSlide() {
wss_elem.innerHTML = wss_array[wss_i];
wss_elem.style.opacity = 1;
setTimeout('wssNext()', 2000);
}
答案 0 :(得分:9)
应使用正确的变量。
使用
wss_i = 0;
而不是
wss_1 = 0;