-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathamazon.js
More file actions
23 lines (20 loc) · 911 Bytes
/
amazon.js
File metadata and controls
23 lines (20 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
document.addEventListener('DOMContentLoaded', () => {
const slides = document.querySelectorAll('.hero1, .hero2, .hero3');
const leftArrow = document.querySelector('.arrow-left');
const rightArrow = document.querySelector('.arrow-right');
let currentIndex = 0;
// Show the first slide
slides[currentIndex].style.opacity = '1';
// Next slide
rightArrow.addEventListener('click', () => {
slides[currentIndex].style.opacity = '0';
currentIndex = (currentIndex + 1) % slides.length; // Loop to first slide
slides[currentIndex].style.opacity = '1';
});
// Previous slide
leftArrow.addEventListener('click', () => {
slides[currentIndex].style.opacity = '0';
currentIndex = (currentIndex - 1 + slides.length) % slides.length; // Loop to last slide
slides[currentIndex].style.opacity = '1';
});
});