-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.js
59 lines (48 loc) · 1.44 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const hambugerMenu = document.querySelector(".hambuger-menu");
const navMenu = document.querySelector(".nav-menu");
const closeBtn = document.querySelector(".close-button");
hambugerMenu.addEventListener("click", () => {
navMenu.classList.toggle("active");
});
closeBtn.addEventListener("click", () => {
navMenu.classList.toggle("active");
});
const questions = document.querySelectorAll(".the-questions");
questions.forEach((questions) => {
questions.addEventListener("click", () => {
questions.classList.toggle("active");
});
});
const slides = document.querySelectorAll(".slide");
const radioButtons = document.querySelectorAll('input[name="radio-btn"]');
const manualBtns = document.querySelectorAll(".manual-btn"); // Select manual buttons
let currentSlide = 0;
function showSlide(index) {
slides.forEach((slide, i) => {
slide.classList.remove("active");
if (i === index) {
slide.classList.add("active");
}
});
radioButtons.forEach((radio, i) => {
radio.checked = i === index;
});
manualBtns.forEach((btn, i) => {
btn.classList.remove("active");
if (i === index) {
btn.classList.add("active");
}
});
}
function nextSlide() {
console.log("working");
currentSlide = (currentSlide + 1) % slides.length;
showSlide(currentSlide);
}
setInterval(nextSlide, 5000);
manualBtns.forEach((btn, i) => {
btn.addEventListener("click", () => {
currentSlide = i;
showSlide(currentSlide);
});
});