-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
26 lines (25 loc) · 919 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const nav = document.querySelector('nav')
nav.onclick = (evt) => {
if (evt.target.tagName.toLowerCase() === 'li') {
nav.querySelector('.active').classList.remove('active')
evt.target.classList.add('active')
console.log(evt.target)
}
}
const aside = document.querySelector('aside')
const gridItems = document.querySelectorAll('.items')
aside.onclick = (evt) => {
if (evt.target.tagName.toLowerCase() === 'li') {
aside.querySelector('.active').classList.remove('active')
evt.target.classList.add('active')
let filterName = evt.target.innerHTML.toLowerCase()
gridItems.forEach(item => {
let itemType = item.getAttribute('item-type')
if (itemType === filterName | filterName === 'all') {
item.classList.remove('hide')
} else {
item.classList.add('hide')
}
})
}
}