-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
20 lines (17 loc) · 846 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function openTab(evt, tabName) {
// Declare all variables
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].className = tabcontent[i].className.replace(" tabcontent-display", "");
}
// Get all elements with class="tablinks" and remove the class "active"
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
// Show the current tab, and add an "active" class to the button that opened the tab
document.getElementById(tabName).className += " tabcontent-display";
evt.currentTarget.className += " active";
evt.currentTarget.parentElement.prepend(evt.currentTarget);
}