21 lines
685 B
JavaScript
21 lines
685 B
JavaScript
const cards = document.querySelectorAll('.card');
|
|
let currentIndex = 0;
|
|
|
|
document.getElementById('next-btn').addEventListener('click', () => {
|
|
const currentCard = cards[currentIndex];
|
|
currentIndex = (currentIndex + 1) % cards.length;
|
|
const nextCard = cards[currentIndex];
|
|
|
|
currentCard.classList.add('hidden');
|
|
nextCard.classList.remove('hidden');
|
|
});
|
|
|
|
document.getElementById('prev-btn').addEventListener('click', () => {
|
|
const currentCard = cards[currentIndex];
|
|
currentIndex = (currentIndex - 1 + cards.length) % cards.length;
|
|
const prevCard = cards[currentIndex];
|
|
|
|
prevCard.classList.remove('hidden');
|
|
currentCard.classList.add('hidden');
|
|
});
|