-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
21 lines (20 loc) · 726 Bytes
/
Copy pathscript.js
File metadata and controls
21 lines (20 loc) · 726 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
document.querySelectorAll('a[href^="#"]').forEach((anchor) => {
anchor.addEventListener("click", function (e) {
e.preventDefault();
document.querySelector(this.getAttribute("href")).scrollIntoView({
behavior: "smooth",
});
});
});
// Form submission handling
document
.getElementById("contact-form")
.addEventListener("submit", function (e) {
e.preventDefault();
// You can add code here to handle form submission, such as sending an email or storing the data.
// For demonstration purposes, let's log the form data to the console.
const formData = new FormData(this);
console.log("Form data:", Object.fromEntries(formData));
// Clear the form inputs
this.reset();
});