1 回答
TA贡献1789条经验 获得超8个赞
好的,我已经找到了如何处理它:
for (let i = 0; i <= avatarsLen; i++){
setTimeout(function(){
if (i > 0){
avatars[i-1].classList.remove("focused-avatar");
};
if (i == avatarsLen) {
return testimonialCarousel();
};
avatars[i].classList.add("focused-avatar");
balloonMessage.style.opacity = 0;
balloonName.style.opacity = 0;
setTimeout(function(){
balloonMessage.innerHTML = balloonContent[i].message;
balloonName.innerHTML = "— " + balloonContent[i].name;
balloonMessage.style.opacity = 1;
balloonName.style.opacity = 1;
}, 650)
}, i*3000); /* <--- The solution lays here. */
添加回答
举报