sozday-mne-sayt/script.js

31 lines
852 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

document.getElementById('contactForm').addEventListener('submit', function(e) {
e.preventDefault();
const formData = new FormData(this);
const data = Object.fromEntries(formData);
console.log('Форма отправлена:', data);
const message = document.getElementById('formMessage');
message.textContent = 'Спасибо! Мы свяжемся с вами в ближайшее время.';
message.style.color = '#4caf50';
this.reset();
setTimeout(() => {
message.textContent = '';
}, 5000);
});
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'
});
}
});
});