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; | |
} | |
}); | |
}); | |
}); | |
// 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'); | |
}); | |
}); | |