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/navigation.js

24 lines
717 B
JavaScript
Raw Normal View History

2023-01-23 00:07:07 -05:00
// 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)