-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathscript.js
More file actions
25 lines (23 loc) · 828 Bytes
/
script.js
File metadata and controls
25 lines (23 loc) · 828 Bytes
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
// toggle hamburger menu (for mobile devices)
function toggleMenu() {
var navLinks = document.querySelector(".nav-links");
var hamburgerIcon = document.getElementById("hamburger-icon");
var xIcon = document.getElementById("x-icon");
// add/remove class from navLinks
navLinks.classList.toggle("active");
// specify the display of hamburgerIcon and xIcon
if(document.querySelector(".nav-links").classList.contains("active")){
hamburgerIcon.style.display = "none";
xIcon.style.display = "block";
}else{
hamburgerIcon.style.display = "block";
xIcon.style.display = "none";
}
}
// scroll to top when clicking the logo
document.querySelector(".logo").addEventListener("click", () => {
window.scrollTo({
top: 0,
behavior: "smooth"
})
})