added javaScript for popup

This commit is contained in:
JSriwongsa 2023-07-04 16:47:08 -05:00
parent 7ea4002a7c
commit 78c8e4f3c5

View file

@ -65,3 +65,20 @@ trigger.forEach((btn) => {
body.classList.add('active');
});
});
//popup
const sorter = document.querySelector('.sort-list');
if(sorter){
const sortLi = sorter.querySelectorAll('li');
sorter.querySelector('.opt-trigger').addEventListener('click', function(){
sorter.querySelector('ul').classList.toggle('show');
});
sortLi.forEach((item) => item.addEventListener('click', function(){
sortLi.forEach((i) => li != this ? li.classList.remove('active'): null);
this.classList.add('active');
sorter.querySelector('.opt-trigger span.value').textContent = this.textContent;
sorter.querySelector('ul').classList.toggle('show')
}))
}