-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
38 lines (34 loc) · 1.3 KB
/
script.js
File metadata and controls
38 lines (34 loc) · 1.3 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
// Basic website functionality
document.addEventListener('DOMContentLoaded', function() {
// Mobile menu toggle
const menuBtn = document.querySelector('.menu-toggle');
const navLinks = document.querySelector('.nav-links');
if (menuBtn && navLinks) {
menuBtn.addEventListener('click', function() {
navLinks.style.display = navLinks.style.display === 'flex' ? 'none' : 'flex';
});
}
// Smooth scroll for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
const target = document.querySelector(this.getAttribute('href'));
if(target) {
e.preventDefault();
target.scrollIntoView({ behavior: 'smooth' });
}
});
});
// Basic form validation
const form = document.querySelector('.contact-form');
if (form) {
form.addEventListener('submit', function(e) {
const name = form.name.value.trim();
const email = form.email.value.trim();
const message = form.message.value.trim();
if (!name || !email || !message) {
e.preventDefault();
alert('Please fill in all fields.');
}
});
}
});