Site logo

Archived topic

Hide a button after a while

3 replies · Started by Marcel on April 10, 2022

Viewing posts 1–4 of 4

My intention is to make a button appear with a delay of a few seconds (and I succeeded - link in the private Information Area, following David's instructions in this post), but I would also like the button to disappear after a while. Do you think there is such a possibility? Thank you.

Hi there,

try:

<script>
setTimeout(() => document.querySelector('.sticky-button').classList.add('show'), 5000);
setTimeout(() => document.querySelector('.sticky-button').classList.remove('show'), 10000);
</script>

So first line is the original code, where it adds the show class after 5000ms
The second line removes the show class after 10,000ms.

David, thanks a lot!

You're welcome

This archived topic is closed to new replies.