forked from Code-Social/official-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
28 lines (25 loc) · 937 Bytes
/
script.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
document.addEventListener('DOMContentLoaded', () => {
const navbarItems = document.querySelectorAll('.navbar ul li');
navbarItems.forEach(item => {
item.addEventListener('mouseover', () => {
const dropdown = item.querySelector('.dropdown');
if (dropdown) {
dropdown.style.display = 'block';
}
});
item.addEventListener('mouseout', () => {
const dropdown = item.querySelector('.dropdown');
if (dropdown) {
dropdown.style.display = 'none';
}
});
});
// Toggle hamburger menu on small screens
const toggleButton = document.querySelector('.toggle-button');
const navbarLinks = document.querySelectorAll('.navbar ul li');
toggleButton.addEventListener('click', () => {
navbarLinks.forEach(link => {
link.classList.toggle('active');
});
});
});