js

mail@pastecode.io avatarunknown
plain_text
2 months 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");
  }
});