Settimeout func

Hello
I would like to make a picture appear and disappear with settimeout in javascript.
That code makes it disappear. How can I make it appear again and then disappear again?


1 <!DOCTYPE html>
2 <html lang="en">   
 3 <head>
 4 <meta charset="UTF-8" />
 5 <meta http-equiv="X-UA-Compatible" content="IE=edge" />
 6 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
 7<title>Document</title>
 8 <style>
 9 #image {
 10 display: block;
 11 width: 300px;
 12 height: 300px;
 13 }
 14 </style>
  15 </head>
  16 <body>
    17 <img id="image" src="some picture" ; />
    18 <script>
      19 let image = document.querySelector("#image");
      20 setTimeout(function () {
        21 image.style.display = "none";
      22 }, 3000);
    23 </script>
  24 </body>
25 </html>

Thanks for any suggestion :grinning:

How many times do you want it to disappear and reappear total?

If it would be able to do it 10 times, that would be nice.
thanks

I would look into setInterval instead or look into using a CSS animation/transition to accomplish the task. So when the page loads, you want this disappear/reappear to happen or are you wanting it to happen when some other event takes place too?

I want to do it with a given timeframe. In every minute for example.

Look into the setInterval. You would need to separate setIntervals. One to fire every minute (forever) and one to repeat 10 times (you will need to create a logic condition that clears the interval after 10 times).

Ok. Thanks for your help. :+1:

If you get stuck, then post your code and ask questions.

Thanks. I will do it. :smiley: