Dropdown disappears when click away

This commit is contained in:
bashrc committed 2019-08-25 13:23:25 +01:00
1 parent da7e8b43e8
commit b70532d4da
2 files changed
+12 -4

No files matched your search

-4
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;
+12
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