const catalogItems = document.querySelectorAll('.select-catalog__item');
const catalogCount = document.querySelector('.select-catalog__title-count');
const updateActiveCount = () => {
const activeCount = [...catalogItems].filter(i => i.classList.contains('_active')).length
catalogCount.innerText = activeCount
if (activeCount > 0) {
catalogCount.classList.add('_active')
} else {
catalogCount.classList.remove('_active')
}
}
for (const item of catalogItems) {
item.onclick = ({ target }) => {
const isActive = target.classList.toggle('_active')
updateActiveCount()
}
}