Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathscript.js
More file actions
Latest commit
25 lines (23 loc) · 828 Bytes
/
Copy pathscript.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)
functiontoggleMenu(){
varnavLinks=document.querySelector(".nav-links");
varhamburgerIcon=document.getElementById("hamburger-icon");
varxIcon=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"
})
})