Remove object over time

Asked

Viewed 32 times

2

Well, I have the following modal

<div id="alerta-imagem">
    As imagens de perfil precisam ter altura e largura proporcionais, com tamanho máximo de 200x200
</div>

I googled a few ways, but I only found the setTimeOut() and setInterval(), but I couldn’t use them, I wanted to know so much about javascript so much with jquery, how do I so that, for example, after 10 seconds this modal gains a display:none

1 answer

3


You can use setTimeout together with jquery’s Hide, follow the example:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div id="modal"> Testeeeeeee </div>

<script>
 
  setTimeout(function() {
    $('#modal').hide();  

  }, 3*1000); // 3 segundos
 
</script>

  • perfect, thank you :3

Browser other questions tagged

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