自动轮播精简版

<script>
var banners = ['index4.jpg', 'index2.jpg','index1.jpg'];
var idx = 0;
setInterval(function(){
if(idx < banners.length){
document.querySelector('.container-lb').style.background = 'url(img/' + banners[idx] + ')';
}else{
idx = 0;
document.querySelector('.container-lb').style.background = 'url(img/' + banners[idx] + ')';
}
idx++;
}, 4000);
</script>

原文地址:https://www.cnblogs.com/TTTK/p/6253056.html