100-project-100-days-website/100_projects/61-a-message-to-pass/main.js

22 lines
605 B
JavaScript
Raw Normal View History

2023-04-23 17:40:22 +03:00
(function(){
const form = document.querySelector('#message-form');
form.addEventListener('submit', function(e){
e.preventDefault()
const message = document.querySelector('#message');
const feedback = document.querySelector('.feedback');
const messageContent = document.querySelector('.message-content');
if(message.value === ''){
feedback.classList.add('show');
setTimeout(function(){
feedback.classList.remove('show')
}, 4000)
} else{
messageContent.textContent = message.value;
message.value = ''
}
})
})()