I have a simple textarea. I want to check this area for text, when you push button and if your textarea is empty it fills it with default email.
const btn = document.getElementById('btn');
let x = document.getElementById('smth');
function putDefaultMail() {
if (x.textContent != null) {
x.textContent = 'defaultmail@gmail.com';
}
}
btn.addEventListener('click', function(e) {
e.preventDefault();
putDefaultMail();
});
<form>
<textarea id="smth"></textarea>
<button id="btn">Sumbit</button>
</form>
But something went wrong. It just calls once.