-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
31 lines (25 loc) · 858 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
27
28
29
30
31
const buttons = document.querySelectorAll('.add-minus-icon')
const items = document.querySelectorAll('li')
buttons.forEach((button, index) => {
button.addEventListener('click', () => {
const img = button.querySelector('img')
const info = items[index].querySelector('p')
if (img.src.includes('icon-plus.svg')) {
img.src = './assets/images/icon-minus.svg'
info.classList.remove('info-hide')
} else {
img.src = './assets/images/icon-plus.svg'
info.classList.add('info-hide')
}
})
})
const changeImage = () => {
const img = document.getElementById('background-pattern')
if (window.innerWidth > 516) {
img.src = './assets/images/background-pattern-desktop.svg'
} else {
img.src = './assets/images/background-pattern-mobile.svg'
}
}
window.addEventListener('resize', changeImage)
changeImage()