let jumbotron = document.querySelector('.jumbotron'); let topImageHolder = document.querySelector('.jumbotron-image[data-order="1"]'); let bottomImageHolder = document.querySelector('.jumbotron-image[data-order="2"]'); let images = jumbotron.getAttribute('data-images').split(','); let delay = jumbotron.getAttribute('data-delay'); let imageIndex = 0; // init bottomImageHolder.src = images[imageIndex]; imageIndex++; function loop() { bottomImageHolder.classList.add('op0'); bottomImageHolder.src = images[imageIndex]; imageIndex++; topImageHolder.classList.add('op0'); topImageHolder.src = images[imageIndex]; imageIndex++; bottomImageHolder.classList.remove('op0'); if (imageIndex >= images.length) { imageIndex = 0; } } setInterval(loop, delay);