document.addEventListener('DOMContentLoaded', function () { const captions = ["Caption 1", "Caption 2", "Caption 3"]; let currentIndex = 0; const captionElement = document.querySelector('.caption'); setInterval(() => { captionElement.classList.add('hidden'); setTimeout(() => { currentIndex = (currentIndex + 1) % captions.length; captionElement.textContent = captions[currentIndex]; captionElement.classList.remove('hidden'); }, 500); }, 4000); });