setTimeout is your friend here. You can add it into the click listener after you set the button to look pressed:
button.classList.add('active'); setTimeout(() => { button.classList.remove('active'); }, 2000);
The 2000 there is the number of milliseconds it should wait before it executes. 2000ms is 2 seconds.
You can see the whole thing in the Codepen at codepen.io/nicm42/pen/OJjdoqe
Cool thanks!
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
setTimeout is your friend here. You can add it into the click listener after you set the button to look pressed:
The 2000 there is the number of milliseconds it should wait before it executes. 2000ms is 2 seconds.
You can see the whole thing in the Codepen at codepen.io/nicm42/pen/OJjdoqe
Cool thanks!