-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
53 lines (47 loc) · 1.87 KB
/
main.js
File metadata and controls
53 lines (47 loc) · 1.87 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
// Mobile menu functionality
document.addEventListener('DOMContentLoaded', function() {
const mobileMenuButton = document.querySelector('.mobile-menu-button');
const mobileMenu = document.querySelector('.mobile-menu');
mobileMenuButton.addEventListener('click', function() {
mobileMenu.classList.toggle('hidden');
});
// Close mobile menu when clicking outside
document.addEventListener('click', function(event) {
if (!mobileMenuButton.contains(event.target) && !mobileMenu.contains(event.target)) {
mobileMenu.classList.add('hidden');
}
});
});
// Smooth scroll for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth'
});
}
});
});
// Newsletter form submission
const newsletterForm = document.querySelector('footer form');
if (newsletterForm) {
newsletterForm.addEventListener('submit', function(e) {
e.preventDefault();
const emailInput = this.querySelector('input[type="email"]');
const email = emailInput.value.trim();
if (email) {
// Here you would typically send this to your backend
alert('Thank you for subscribing to our newsletter!');
emailInput.value = '';
}
});
}
// Course enrollment buttons
document.querySelectorAll('.bg-indigo-600.text-white.px-4.py-2.rounded-md').forEach(button => {
button.addEventListener('click', function() {
const courseTitle = this.closest('.bg-white').querySelector('h3').textContent;
alert(`You have enrolled in ${courseTitle}!`);
});
});