How to show an element for a few seconds and then hide it?

Asked

Viewed 255 times

8

Is there any way I can inform a visible : true for time? I want it to be true only for a few seconds then come back to false.

  • 1

    Behold timeout and also do the tour to learn about the functioning of the community.

1 answer

11


Serves like this?

function esconde() {
  document.getElementById("exemplo").style.visibility = "hidden";
}
setTimeout(esconde, 3000);
<div id="exemplo" style="visibility: visible">Vou sumir em 3 segundos</div>

I put in the Github for future reference.

setTimeout()

  • Yes I understood your code. but I need the image to be True for 3 seconds and the false sticker... It’s like?

  • 2

    Just reverse it, you can use your creativity to adapt and do new things. But I changed the answer especially for you.

  • 3

    Now the function Mostra hides instead of showing :P

  • 1

    @bfavaretto boring :P

  • 2

    Being boring works :D

Browser other questions tagged

You are not signed in. Login or sign up in order to post.