【发布时间】:2017-04-24 19:03:27
【问题描述】:
我使用这个 jquery 代码使我的推荐部分工作:
$(document).ready(function () {
var testimonialItem = $(".testimonial-wrapper .testimonial-item");
var lengthOfItem = testimonialItem.length;
var counter = 0;
testimonialItem.hide();
setTimeout(function(){
startIteration(counter);
}, 1000);
function startIteration(counter) {
testimonialItem.eq(counter).fadeIn('slow', function() {
if(counter<=lengthOfItem){
setTimeout(function(){
testimonialItem.fadeOut('slow',function(){
if (counter == lengthOfItem) {
counter = 0;
}
else{
counter++;
}
setTimeout(function(){
startIteration(counter);
}, 500);
});
}, 2000);
}
});
}
});
通过我的pen,我意识到离开链接几分钟后,当我返回时,滑块消失了。 有没有办法解决这个问题,让滑块一直循环?
另外,我如何添加导航项目符号,以便每次推荐发生变化时,项目符号也会改变颜色,如您在示例图像中看到的那样?
【问题讨论】:
标签: javascript jquery css