-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
30 lines (26 loc) · 975 Bytes
/
script.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
// Scroll effect for navbar
// Add scroll event listener
window.addEventListener('scroll', function() {
var navbar = document.querySelector('.navbar');
var socialMediaBarHeight = document.querySelector('.social-media-bar').offsetHeight;
// If the user scrolls past the social media bar
if (window.scrollY > socialMediaBarHeight) {
navbar.classList.add('fixed'); // Make the navbar fixed at the top
} else {
navbar.classList.remove('fixed'); // Return to normal flow when scrolled up
}
});
// Form validation and submission
const form = document.getElementById('contact-form');
form.addEventListener('submit', function(e) {
e.preventDefault();
const name = form.name.value;
const email = form.email.value;
const message = form.message.value;
if (name && email && message) {
alert('Message sent successfully!');
form.reset();
} else {
alert('Please fill out all fields.');
}
});