document.addEventListener('DOMContentLoaded', () => { // Existing functionality: Redirect to movie details page when clicked const movies = document.querySelectorAll('.movie'); movies.forEach(movie => { movie.addEventListener('click', () => { // Redirect to movie details page when clicked const link = movie.querySelector('a'); if (link) { window.location.href = link.href; } }); }); // New functionality: Create and handle "Go to Top" button const goToTopButton = document.createElement('button'); goToTopButton.classList.add('go-to-top'); goToTopButton.innerHTML = ` `; document.body.appendChild(goToTopButton); window.addEventListener('scroll', () => { if (window.scrollY > 200) { goToTopButton.style.display = 'block'; } else { goToTopButton.style.display = 'none'; } }); goToTopButton.addEventListener('click', () => { window.scrollTo({ top: 0, behavior: 'smooth' }); }); }); // Get all elements with the class "option" const options = document.querySelectorAll('.option'); // Attach a click event listener to each option element options.forEach(option => { option.addEventListener('click', function() { // Remove the "active" class from all option elements options.forEach(el => el.classList.remove('active')); // Add the "active" class to the clicked option element this.classList.add('active'); }); });