I need to make it so that by clicking on an element, another element appears with an appearance animation and after 5 seconds also disappears.

Separately, I know how to make the element appear and hide with animation, but I don’t know how to use settimeout.

Here is a sample code:

.box-size { height: 200px; width: 200px; border: 1px solid #000; } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <form> <div class="box-size"> <a class="click-btn">Нажать</a> </div> <button class="button">Кнопка</button> </form> <script> $(".click-btn").click(function() { $('.button').appendTo(this); }); </script> 

    1 answer 1

    The button is initially made invisible, when clicked, show and set a timeout for 2 seconds to hide.

     $(".click-btn").click(function() { $('.button').show(); setTimeout(function() { $('.button').hide(); }, 2000); }); 
     .box-size { height: 200px; width: 200px; border: 1px solid #000; } .button { display: none; } 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <form> <div class="box-size"> <a class="click-btn">Нажать</a> </div> <button class="button">Кнопка</button> </form>