-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
40 lines (35 loc) · 1.21 KB
/
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
29
30
31
32
33
34
35
36
37
38
39
40
// Function to enable smooth scrolling for navigation links
function enableSmoothScrolling() {
$("a.nav-link").on("click", function (event) {
if (this.hash !== "") {
event.preventDefault();
var hash = this.hash;
$("html, body").animate(
{
scrollTop: $(hash).offset().top,
},
800, // Animation duration in milliseconds
function () {
window.location.hash = hash;
}
);
}
});
}
// Function to dynamically update the current year in the footer
function updateCurrentYear() {
var currentYear = new Date().getFullYear();
$("#currentYear").text(currentYear);
}
// Function to close the mobile navigation menu after clicking a link
function closeMobileMenuOnLinkClick() {
$(".navbar-collapse a.nav-link").on("click", function () {
$(".navbar-toggler").click(); // Simulate a click on the menu button
});
}
// Wait for the document to be fully loaded before running the script
document.addEventListener("DOMContentLoaded", function () {
enableSmoothScrolling();
updateCurrentYear();
closeMobileMenuOnLinkClick();
});