-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
31 lines (23 loc) · 933 Bytes
/
app.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
// JavaScript code for enabling navigation buttons with smooth scrolling
// JavaScript code for enabling smooth scrolling for navigation buttons
// Get all navigation links
const links = document.querySelectorAll('.link');
// Function to handle link click event
function handleLinkClick(event) {
event.preventDefault();
// Get the target section ID from the href attribute
const targetSectionId = this.querySelector('a').getAttribute('href');
// Get the target section element
const targetSection = document.querySelector(targetSectionId);
// Scroll to the target section
window.scrollTo({
top: targetSection.offsetTop,
behavior: 'smooth'
});
}
const hamburger=document.querySelector(".hamburger");
const navMenu=document.querySelector(".nav-menu");
hamburger.addEventListener("click",()=>{
hamburger.classList.toggle("active");
navMenu.classList.toggle("active");
})