-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscripts.js
49 lines (38 loc) · 1.38 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// JavaScript for Dropdown Menu and Smooth Scrolling
document.addEventListener('DOMContentLoaded', function () {
// Smooth scrolling for links
const links = document.querySelectorAll('a[href^="#"]');
links.forEach(link => {
link.addEventListener('click', function (e) {
e.preventDefault();
const targetId = this.getAttribute('href').substring(1);
const targetElement = document.getElementById(targetId);
if (targetElement) {
window.scrollTo({
top: targetElement.offsetTop,
behavior: 'smooth'
});
}
});
});
// Dropdown menu toggle
const dropdown = document.querySelector('.dropdown');
dropdown.addEventListener('mouseenter', () => {
const dropdownMenu = dropdown.querySelector('.dropdown-menu');
dropdownMenu.style.display = 'block';
});
dropdown.addEventListener('mouseleave', () => {
const dropdownMenu = dropdown.querySelector('.dropdown-menu');
dropdownMenu.style.display = 'none';
});
});
// JavaScript to toggle the mobile navigation menu
function toggleNav() {
document.querySelector(".mobile-nav").classList.toggle("active");
}
function printpage() {
window.print();
}
function reload() {
location.reload();
}