How can I write a function that undoes the action after a few seconds? I am adding a class to an element with the purpose to create a short animation. I know I can set the animation time with css, but how do I remove the class after a few seconds? Should I create another animation setTimeout()?
Here is my code:
const copyAnimation = (item) => {
item.classList.add('copied');
};
copyTextArea.addEventListener('click', () => {
copyAnimation(clonedCode);
});