-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
26 lines (21 loc) · 787 Bytes
/
script.js
File metadata and controls
26 lines (21 loc) · 787 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
document.addEventListener('DOMContentLoaded', function() {
const menu = document.getElementById('menu');
const sections = document.querySelectorAll('main section');
// Función para mostrar la sección seleccionada y ocultar las demás
function showSection(sectionId) {
sections.forEach(section => {
if (section.id === sectionId) {
section.classList.add('active');
} else {
section.classList.remove('active');
}
});
}
// Evento para cambiar de sección cuando se selecciona una opción del menú
menu.addEventListener('change', function() {
const selectedSectionId = menu.value;
showSection(selectedSectionId);
});
// Mostrar la primera sección por defecto al cargar la página
showSection(sections[0].id);
});