-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
53 lines (41 loc) · 1.79 KB
/
script.js
File metadata and controls
53 lines (41 loc) · 1.79 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
41
42
43
44
45
46
47
48
49
50
51
52
53
// Get the hamburger and nav menu elements
const hamburger = document.querySelector(".hamburger");
const navMenu = document.querySelector(".nav-menu");
// Add click event listener to the hamburger
hamburger.addEventListener("click", () => {
hamburger.classList.toggle("active");
navMenu.classList.toggle("active");
})
// Get the button and paragraph elements
const submitClick = document.querySelector("#submit-button");
const successMessage = document.querySelector("#submit-success");
// Add click event listener to the button
// Change the display style of the paragraph to 'block' to make visible
submitClick.addEventListener('click', function() {
successMessage.style.display = 'block';
})
// Clear form input fields
function clearFormAfterSubmission() {
// Allow the form to submit normally, then clear input fields after a short delay
setTimeout(function() {
// Clear input fields
document.getElementById("name-box").value= '';
document.getElementById("email-box").value= '';
document.getElementById("text-box").value= '';
}, 100); // 100 milliseconds delay before clearing the form
}
document.getElementById("externalLink").addEventListener("click", function(event) {
var confirmation = confirm("Warning: This link will open in a new window. Do you want to continue?");
if (!confirmation) {
event.preventDefault(); // Prevent the default behavior if the user cancels
}
});
document.addEventListener("DOMContentLoaded", function() {
var menuItems = document.querySelectorAll('.nav-link');
menuItems.forEach(function(item) {
item.addEventListener('click', function() {
// Toggle the class that controls the display of the navigation menu
document.querySelector('.nav-menu').classList.toggle('active');
});
});
});