-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
23 lines (21 loc) · 880 Bytes
/
script.js
File metadata and controls
23 lines (21 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Selecciona el botón del menú móvil y la lista de enlaces
const mobileMenuBtn = document.querySelector('.mobile-menu-btn');
const navLinks = document.querySelector('.nav-links');
// Agrega un evento de clic al botón
mobileMenuBtn.addEventListener('click', () => {
navLinks.classList.toggle('active'); // Activa o desactiva la clase 'active'
document.body.classList.toggle('menu-open'); // Evita el scroll cuando el menú está abierto
});
// Smooth scrolling
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
window.scrollTo({
top: target.offsetTop - 70,
behavior: 'smooth'
});
}
});
});