@prasid/dropdown-npm
Version: 
This for dropdown creation uses two arguments
22 lines • 615 B
JavaScript
DropDown = function (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'
    })
}
dropdownHandling = function () {
    const All = document.querySelectorAll('.dropdown-item')
    All.forEach((item) => {
        item.style.display = 'none'
        item.classList.remove('dropdown-item')
    })
}
export {
    DropDown,
    dropdownHandling
}