-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
23 lines (20 loc) · 913 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Smooth scroll to section when clicking nav links
document.querySelectorAll('nav ul li a').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href').substring(1);
const targetSection = document.getElementById(targetId);
window.scrollTo({
top: targetSection.offsetTop - document.querySelector('header').offsetHeight,
behavior: 'smooth'
});
});
});
// Form submission (you can add form validation and AJAX)
document.getElementById('contact-form').addEventListener('submit', function(e) {
e.preventDefault();
const formData = new FormData(this);
// Handle form submission (e.g., send data to server)
console.log(formData.get('name'), formData.get('email'), formData.get('message'));
alert('Message sent successfully!');
});