-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
48 lines (33 loc) · 1.15 KB
/
index.js
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
41
42
43
44
45
46
47
48
document.addEventListener("DOMContentLoaded", function() {
// toggle the navbar
const navList = document.getElementById("navList");
const toggleButton = document.getElementById("toggleButton");
const about = document.getElementById("abt")
const content = document.getElementById("about-content")
toggleButton.addEventListener("click", function() {
navList.classList.toggle("show");
});
about.addEventListener("click", function() {
content.classList.toggle("show");
console.log("show2 created");
});
// email submission
const form = document.querySelector("form");
form.addEventListener("submit", async function(event) {
event.preventDefault();
const formData = new FormData(form);
const response = await fetch(form.action, {
method: "POST",
body: formData,
headers: {
Accept: "application/json",
},
});
if (response.ok) {
alert("Message sent successfully!");
form.reset();
} else {
alert("Oops! Something went wrong.");
}
});
});