-
Notifications
You must be signed in to change notification settings - Fork 0
/
scripts.js
33 lines (29 loc) · 989 Bytes
/
scripts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* When the user clicks on the button,
toggle between hiding and showing the dropdown content */
function myFunction() {
document.getElementById("myDropdown").classList.toggle("show");
}
function reveal() {
document.getElementById("myInfo").classList.toggle("reveal");
}
// Close the dropdown menu if the user clicks outside of it
window.onclick = function(event) {
if (!event.target.matches('.dropbtn')) {
var dropdowns = document.getElementsByClassName("dropdown-content");
for (i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
if (!event.target.matches('.infobtn')) {
var info = document.getElementsByClassName("info-content");
for (i = 0; i < info.length; i++) {
var openInfo = info[i];
if (openInfo.classList.contains('reveal')) {
openInfo.classList.remove('reveal');
}
}
}
}