school website
easy website to help studentsunknown
java
9 months ago
907 B
14
Indexable
// Hamburger menu toggle
const hamburger = document.querySelector('.hamburger');
const navLinks = document.querySelector('.nav-links');
hamburger.addEventListener('click', () => {
navLinks.classList.toggle('active');
});
// Event slider
const events = document.querySelectorAll('.event');
const prevBtn = document.getElementById('prevBtn');
const nextBtn = document.getElementById('nextBtn');
let currentIndex = 0;
function showEvent(index) {
events.forEach(event => event.classList.remove('active'));
events[index].classList.add('active');
}
prevBtn.addEventListener('click', () => {
currentIndex = (currentIndex - 1 + events.length) % events.length;
showEvent(currentIndex);
});
nextBtn.addEventListener('click', () => {
currentIndex = (currentIndex + 1) % events.length;
showEvent(currentIndex);
});
// Initialize
showEvent(currentIndex);
Editor is loading...
Leave a Comment