-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
24 lines (20 loc) · 762 Bytes
/
Copy pathapp.js
File metadata and controls
24 lines (20 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const image = document.querySelector('.about-img')
const aboutButton = document.querySelectorAll('.tab-btn')
const contents = document.querySelectorAll('.content')
aboutButton.forEach((button)=>{
button.addEventListener('click', (e)=>{
const target = e.currentTarget
aboutButton.forEach((btn)=>{
btn.classList.remove('active')
})
target.classList.add('active')
image.childNodes[1].setAttribute('src', `./${target.dataset.id}.png`)
contents.forEach((content)=>{
if(content.getAttribute('id') == target.dataset.id){
content.classList.add('active')
}else{
content.classList.remove('active')
}
})
})
})