document.getElementById('animateButton').addEventListener('click', function() { var pageContent = document.getElementById('pageContent'); // Add the 'fade-out' class to trigger the animation pageContent.classList.add('fade-out'); // Optional: Remove the 'fade-out' class after the animation completes to reset the state setTimeout(function() { pageContent.classList.remove('fade-out'); }, 2000); // This should match the duration of the animation });