second question..
I've made a litte feature in Javascript, When you click on my logo, my email is copied. This one works. Here you got the code.
const btnCopy = document.querySelector('.btn-copy');
const txtCopy = document.querySelector('.box p');
btnCopy.addEventListener('click', () => {
navigator.clipboard.writeText(txtCopy.innerText);
})
<div class="box">
<p style="display: none;">myemail@gmail.com</p>
<button class="btn-copy"><img src="ressources/logo.svg" class="logo"><img src="ressources/logo.svg" class="logo"></button>
</div>
I would like to know how to create an alert when the email is copied.. If you can help me Thank you, enjoy your weekend :)
navigator.clipboard.writeText() This returns a promise and it can be handled like any async task.
const btnCopy = document.querySelector('.btn-copy');
const txtCopy = document.querySelector('.box p');
btnCopy.addEventListener('click', () => {
navigator.clipboard.writeText(txtCopy.innerText).then(() => {
//show scuccess message.
alert('Email copeid successfully')
}).catch(() => {
//show error message.
alert('Something went wrong!')
});
})
<div class="box">
<p style="display: none;">myemail@gmail.com</p>
<button class="btn-copy"><img src="ressources/logo.svg" class="logo"><img src="ressources/logo.svg" class="logo"></button>
</div>