You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
522 B

const contents = document.querySelectorAll('.content')
const listItems = document.querySelectorAll('nav ul li')
listItems.forEach((item, idx) => {
item.addEventListener('click', () => {
hideAllContents()
hideAllItems()
item.classList.add('active')
contents[idx].classList.add('show')
})
})
function hideAllContents() {
contents.forEach(content => content.classList.remove('show'))
}
function hideAllItems() {
listItems.forEach(item => item.classList.remove('active'))
}