-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
39 lines (32 loc) · 971 Bytes
/
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
window.onload = main;
function main() {
let bttns = document.querySelectorAll('.bttn');
for (let bttn of bttns) {
bttn.addEventListener('click', toggle);
}
function toggle(event) {
let status = event.target.innerHTML;
let id = event.target.id;
let block;
if (id == 'blk1') {
block = document.querySelector('#gp1');
} else if (id == 'blk2') {
block = document.querySelector('#gp2');
} else if (id == 'blk3') {
block = document.querySelector('#gp3');
} else if (id == 'blk4') {
block = document.querySelector('#gp4');
} else if (id == 'blk5'){
block = document.querySelector('#gp5')
} else if (id == 'blk6'){
block = document.querySelector('#gp6')
}
if (status == 'Show') {
block.classList.toggle('Off');
event.target.innerHTML = 'Hide';
} else {
block.classList.toggle('Off');
event.target.innerHTML = 'Show';
}
}
}