38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
// Sample Web Page JavaScript
|
|
|
|
// CTA Button functionality
|
|
document.getElementById('ctaBtn').addEventListener('click', function() {
|
|
alert('Welcome! Let\'s get started with your web application.');
|
|
console.log('CTA button clicked');
|
|
});
|
|
|
|
// Smooth scrolling for navigation 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',
|
|
block: 'start'
|
|
});
|
|
}
|
|
});
|
|
});
|
|
|
|
// Contact form submission
|
|
document.getElementById('contactForm').addEventListener('submit', function(e) {
|
|
e.preventDefault();
|
|
const email = this.querySelector('input[type="email"]').value;
|
|
const message = this.querySelector('textarea').value;
|
|
|
|
console.log('Form submitted:', { email, message });
|
|
alert('Thank you for your message! We will get back to you soon.');
|
|
this.reset();
|
|
});
|
|
|
|
// Log page load
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
console.log('Page loaded successfully');
|
|
});
|