js
unknown
plain_text
2 years ago
394 B
2
Indexable
const dropdownButton = document.getElementById("dropdownButton"); const dropdownMenu = document.querySelector(".dropdown-menu"); dropdownButton.addEventListener("click", function() { dropdownMenu.classList.toggle("show"); }); document.addEventListener("click", function(event) { if (!dropdownButton.contains(event.target)) { dropdownMenu.classList.remove("show"); } });
Editor is loading...