我的JavaScript幻灯片显示有点不稳定。当我加载页面时,幻灯片放映图片可见,但它显示幻灯片中的全部照片。
几秒钟之后,它会解压缩到一张照片显示,然后以5秒的速度翻转每张照片。“
然而,无论我做什么,它仍然会在开头显示所有图片,这就失败了......
这是我的HTML:
<div class="container">
<div style="display: inline-block; ">
<img class="mySlides" src="../images/fullshot1.jpg">
</div>
<div style="display: inline-block; ">
<img class="mySlides2" src="../images/unnamed.jpg">
</div>
<div style="display: inline-block; ">
<img class="mySlides3" src="../images/fullshot2.jpg">
</div>
</div>
这是我的Jquery / JavaScript:
$(document).ready(function() {
console.log( "document loaded" );
//declare section variables
var currentIndex = 0,
items = $('.container div'),
itemAmt = items.length;
//how to click and make it work
function cycleItems() {
var item = $('.container div').eq(currentIndex);
items.hide();
item.css('display','inline-block');
}
//interval time
var autoSlide = setInterval(function() {
currentIndex += 1;
if (currentIndex > itemAmt - 1) {
currentIndex = 0;
}
cycleItems();
}, 3000);
//this closes the doc ready
});
任何人都可以帮我解决这个问题吗?谢谢!