20 lines
802 B
JavaScript
20 lines
802 B
JavaScript
|
|
/* dropdown menu for mobile users, used https://www.w3schools.com/howto/howto_js_dropdown.asp
|
||
|
|
When the user clicks on the button,
|
||
|
|
toggle between hiding and showing the dropdown content */
|
||
|
|
function mobileDropdown() {
|
||
|
|
document.getElementById("dropdown-box").classList.toggle("show-dropdown");
|
||
|
|
}
|
||
|
|
|
||
|
|
// Close the dropdown menu if the user clicks outside of it
|
||
|
|
window.onclick = function(event) {
|
||
|
|
if (!event.target.matches('.nav-baselink-mobile')) {
|
||
|
|
var dropdowns = document.getElementsByClassName("dropdown-content");
|
||
|
|
var i;
|
||
|
|
for (i = 0; i < dropdowns.length; i++) {
|
||
|
|
var openDropdown = dropdowns[i];
|
||
|
|
if (openDropdown.classList.contains('show-dropdown')) {
|
||
|
|
openDropdown.classList.remove('show-dropdown');
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|