-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
36 lines (29 loc) · 922 Bytes
/
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
(function () {
"use strict";
const tabs = document.querySelectorAll("#tabs > ul > li >a");
tabs.forEach(tab => {
tab.addEventListener('click', selectTab);
});
function selectTab(event) {
event.preventDefault();
tabs.forEach(tab => {
tab.removeAttribute("class");
});
event.target.className = "active";
const thisTab = event.target.getAttribute("href");
const thisContent = document.querySelector(thisTab);
const oldContent = document.querySelector(".visible");
oldContent.className = "visuallyhidden";
oldContent.addEventListener(
"transitionend",
function () {
oldContent.className = "hidden";
thisContent.className = "visible visuallyhidden";
setTimeout(function () {
thisContent.classList.remove("visuallyhidden");
}, 20);
},
{ capture: false, once: true, passive: false }
);
}
})();