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

8

How can I report a visible : true per time? I want it to be true only for a few seconds then return to false .

    
asked by anonymous 29.08.2015 / 21:46

1 answer

11

Does this work?

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

setTimeout()

    
29.08.2015 / 21:57