自动切换重叠的图像

Toggle automatically through images which lie upon each other

有五张图片彼此重叠,我想自动(每秒)在所有图片之间切换。知道如何处理吗?

https://dstruning.com

您可以使用 window.setInterval 和 jQuery 来完成,如下所示:

let currentImage = 0;

// Set interval will call the function every 1000 milliseconds (1 second)
window.setInterval(function(){
  // Let's select which image we want to show.
  currentImage += 1;
  // Hide all images
  $('img').hide();
  // Show only image you want to show currently. 
  // We're using %5 to always get numbers between 0 and 4
  $('img:nth(' + (currentImage % 5) + ')').show();
}, 1000);