I want to add a 'Copied!' animation to my javascript that triggers when you click on a link. I want it to appear next to the mouse and disappear after 2 seconds of appearing.
I went hunting on the internet for similar animation examples but couldn't find anything.
Apologies if this is a tall order of a question.
function copy(that){
var inp =document.createElement('input');
document.body.appendChild(inp)
inp.value =that.textContent
inp.select();
document.execCommand('copy',false);
inp.remove();
}
If you just want to delete the element 2 seconds later, you can use setTimeout:
setTimeout(() => inp.remove(), 2000);