Clickable Dropdown
Click on the button to open the dropdown menu.
function myFunction() { document.getElementById("myDropdown").classList.toggle("show"); }
// Close the dropdown if the user clicks outside of it window.onclick = function(event) { if (!event.target.matches('.dropbtn')) { var dropdowns = document.getElementsByClassName("dropdown-content"); var i; for (i = 0; i < dropdowns.length; i++) { var openDropdown = dropdowns[i]; if (openDropdown.classList.contains('show')) { openDropdown.classList.remove('show'); } } } }
Hoverable Dropdown
Move the mouse over the button to open the dropdown menu.