js

mail@pastecode.io avatar
unknown
plain_text
a year ago
394 B
0
Indexable
Never
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");
  }
});