-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
40 lines (31 loc) · 1.54 KB
/
script.js
File metadata and controls
40 lines (31 loc) · 1.54 KB
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
pureScriptTab = (selector1) => {
var selector = document.querySelectorAll(selector1);
selector.forEach((el, index) => {
nav = el.querySelectorAll(' nav'),
ul = el.querySelectorAll('ul'),
li = el.querySelectorAll('li'),
a = el.querySelectorAll('a'),
main = el.querySelector('main');
a.forEach((element, index) => {
element.style.cursor = 'pointer';
element.addEventListener('click', (event) => {
event.preventDefault();
event.stopPropagation();
var ul = event.target.closest('nav'),
main = ul.nextElementSibling,
item_a = ul.querySelectorAll('a'),
section = main.querySelectorAll('section');
item_a.forEach((ela, ind) => {
ela.classList.remove('tabItemActive');
});
event.target.classList.add('tabItemActive');
section.forEach((element1, index) => {
//console.log(element1);
element1.classList.remove('tabContentActive');
});
var target = event.target.target;
document.getElementById(target).classList.add('tabContentActive');
});
});
});
};