-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
28 lines (22 loc) · 997 Bytes
/
Copy pathscript.js
File metadata and controls
28 lines (22 loc) · 997 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
25
26
// Smooth scrolling for navigation links
document.querySelectorAll('nav a').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href').substring(1);
const target = document.getElementById(targetId);
window.scrollTo({
top: target.offsetTop - 20,
behavior: 'smooth'
});
});
});
// Form submission handling
document.querySelector('form').addEventListener('submit', function(e) {
e.preventDefault();
const name = document.getElementById('name').value;
const email = document.getElementById('email').value;
const message = document.getElementById('message').value;
// You can add code here to handle form submission, e.g., send data to a server or display a thank you message.
// For now, we'll just display an alert.
alert(`Form submitted with the following data:\nName: ${name}\nEmail: ${email}\nMessage: ${message}`);
});