-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
40 lines (35 loc) · 1.22 KB
/
script.js
File metadata and controls
40 lines (35 loc) · 1.22 KB
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
32
33
34
35
36
37
38
39
40
// Smooth scrolling for navigation links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
// Function to scroll to contact form
function scrollToContact() {
document.querySelector('#contacto').scrollIntoView({
behavior: 'smooth'
});
}
// Form submission handling
document.getElementById('contact-form').addEventListener('submit', function(e) {
e.preventDefault();
// Get form data
const formData = new FormData(this);
const data = Object.fromEntries(formData);
// Here you would typically send the data to your server
// For now, we'll just show a success message
alert('¡Gracias por contactarnos! Nos pondremos en contacto contigo pronto.');
this.reset();
});
// Add scroll-based header styling
window.addEventListener('scroll', function() {
const header = document.querySelector('header');
if (window.scrollY > 50) {
header.style.backgroundColor = 'rgba(255, 255, 255, 0.95)';
} else {
header.style.backgroundColor = 'white';
}
});