CoolFace
Apppublic

akhaliq/anycoder-coffee-image

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
script.js35 linesDownload Raw Back to js
1document.addEventListener('DOMContentLoaded', function() {2  // Mobile menu toggle3  const mobileMenuBtn = document.getElementById('mobile-menu-btn');4  const nav = document.getElementById('nav');5  6  mobileMenuBtn.addEventListener('click', function() {7    nav.classList.toggle('active');8  });9  10  // Close mobile menu when clicking on a link11  const navLinks = document.querySelectorAll('.nav-link');12  navLinks.forEach(link => {13    link.addEventListener('click', function() {14      nav.classList.remove('active');15    });16  });17  18  // Smooth scrolling for anchor links19  document.querySelectorAll('a[href^="#"]').forEach(anchor => {20    anchor.addEventListener('click', function(e) {21      e.preventDefault();22      23      const targetId = this.getAttribute('href');24      if (targetId === '#') return;25      26      const targetElement = document.querySelector(targetId);27      if (targetElement) {28        window.scrollTo({29          top: targetElement.offsetTop - 70,30          behavior: 'smooth'31        });32      }33    });34  });35});