自动切换彼此重叠的图像

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

https://dstruning.com

jiajiadelan 回答:自动切换彼此重叠的图像

您可以使用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);
本文链接:https://www.f2er.com/3101981.html

大家都在问