Dropdown disappears when click away

master
Bob Mottram 2019-08-25 13:23:25 +01:00
parent da7e8b43e8
commit b70532d4da
2 changed files with 12 additions and 4 deletions

View File

@ -562,10 +562,6 @@ input[type=submit]:hover {
padding: 5% 0px;
}
.dropbtn {
opacity: 1.0;
}
/* The container <div> - needed to position the dropdown content */
.dropdown {
margin: 10px auto;

View File

@ -991,6 +991,18 @@ def clickToDropDownScript() -> str:
script= \
'function dropdown() {' \
' document.getElementById("myDropdown").classList.toggle("show");' \
'}' \
'window.onclick = function(event) {' \
" if (!event.target.matches('.dropdown')) {" \
' 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');" \
' }' \
' }' \
' }' \
'}'
return script