-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
52 lines (48 loc) · 1.23 KB
/
main.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
// "use strict";
const navLink = document.querySelectorAll(".navigation__link");
const navBtn = document.querySelector(".navigation__btn");
const links = document.querySelectorAll("a");
const button = document.querySelectorAll("button");
const inputs = document.querySelectorAll("input");
const checkbox = document.querySelector(".navigation__checkbox");
navLink.forEach((el) => (el.tabIndex = -1));
let navState = false;
const navBtnHandler = function () {
navState ? (navState = false) : (navState = true);
if (navState) {
links.forEach((el) => {
el.tabIndex = -1;
});
button.forEach((el) => {
el.tabIndex = -1;
});
inputs.forEach((el) => {
el.tabIndex = -1;
});
navLink.forEach((el) => {
el.tabIndex = 0;
});
navBtn.tabIndex = 0;
console.log(1);
} else {
links.forEach((el) => {
el.tabIndex = 0;
});
button.forEach((el) => {
el.tabIndex = 0;
});
inputs.forEach((el) => {
el.tabIndex = 0;
});
navLink.forEach((el) => {
el.tabIndex = -1;
});
navBtn.tabIndex = 0;
}
};
navBtn.addEventListener("click", navBtnHandler);
navLink.forEach((el) => {
el.addEventListener("click", () => {
checkbox.checked = false;
});
});