@prasid/odin-dropdown
Version:
Creating multiple dropdown function is here
18 lines • 576 B
JavaScript
export function DropDown(target, content) {
content.style.display = 'none'
target.addEventListener('click', () => {
if (content.style.display === 'none') {
dropdownHandling()
content.style.display = 'block'
content.classList.add('dropdown-item')
}
else content.style.display = 'none'
})
}
export function dropdownHandling(){
const All = document.querySelectorAll('.dropdown-item')
All.forEach((item) => {
item.style.display = 'none'
item.classList.remove('dropdown-item')
})
}