-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
26 lines (23 loc) · 731 Bytes
/
scripts.js
File metadata and controls
26 lines (23 loc) · 731 Bytes
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
const butts = [...document.getElementsByClassName('section-title')];
butts.forEach(function (butt) {
butt.addEventListener('click', function () {
this.classList.toggle('accordion-active');
const panel = this.nextElementSibling;
if (panel.style.maxHeight) {
panel.style.maxHeight = null;
} else {
panel.style.maxHeight = panel.scrollHeight + 'px';
}
})
});
const sects = [...document.getElementsByClassName('section')];
const panels = [...document.getElementsByClassName('panel')];
sects.forEach(function (sect) {
sect.addEventListener('mouseleave', function () {
panels.forEach(panel => {
if (panel.style.maxHeight) {
panel.style.maxHeight = null;
}
})
})
});