📜  图像连续变化的 div - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:40.004000             🧑  作者: Mango

代码示例1
//source : stackoverflow.com
// change images in a div tag after interval

$(document).ready(function () {
  var imageFile = ["Image.jpg", "Image1.jpg", "Image2.jpg", "Image4.jpg"];
  var currentIndex = 0;
  setInterval(function () {
    if (currentIndex == imageFile.length) {
      currentIndex = 0;
    }
    $(".topstrip").css('background-image', 'url("/static/img/website/banner/' + imageFile[currentIndex++] + '")');
  }, 3000);
});