-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
32 lines (26 loc) · 1.02 KB
/
index.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
document.addEventListener('DOMContentLoaded', function() {
var dropdown = document.querySelector('.dropdown2');
dropdown.addEventListener('mouseover', function() {
document.querySelector('.dropdown-content').style.display = 'block';
});
dropdown.addEventListener('mouseout', function() {
document.querySelector('.dropdown-content').style.display = 'none';
});
});
function toggleDropdown() {
var dropdown = document.getElementById("dropdown");
if (dropdown.style.display === "block") {
dropdown.style.display = "none";
} else {
dropdown.style.display = "block";
}
}
// Close the dropdown if the user clicks outside of it
window.onclick = function (event) {
if (!event.target.matches('.hamburger-icon')) {
var dropdown = document.getElementById("dropdown");
if (dropdown.style.display === "block") {
dropdown.style.display = "none";
}
}
};