1
Fork 0
This repository has been archived on 2024-05-27. You can view files and clone it, but cannot push or open issues or pull requests.
Nexus-Polestar/public/scripts/navigation.js
2023-07-23 20:45:17 -04:00

24 lines
No EOL
717 B
JavaScript
Executable file

// Credit: Tabbed Navigation by Casey Jardin
// Source: https://codepen.io/alpha1337/pen/mxWBpq
setTimeout(() => {
const _tabs = document.querySelectorAll('[data-tab]')
const _content = document.getElementsByClassName('active')
const toggleContent = function() {
if (!this.classList.contains("active")) {
Array.from(_content).forEach( item => {
item.classList.remove('active')
})
this.classList.add('active')
let currentTab = this.getAttribute('data-tab'),
_tabContent = document.getElementById(currentTab)
_tabContent.classList.add('active')
}
}
Array.from(_tabs).forEach( item => {
item.addEventListener('click', toggleContent)
})
}, 1000)