Tell me please, I have a setTimeOut() method that performs the specified function once after a certain amount of time, but I need the specified function to be executed every time after a certain interval.

    2 answers 2

     setInterval('функция', врСмя Π² миллисСкундах); 
       setInterval("functionName()",1000); // Π³Π΄Π΅ functionName - имя Π²Ρ‹Π·Ρ‹Π²Π°Π΅ΠΌΠΎΠΉ Ρ„ΡƒΠ½ΠΊΡ†ΠΈΠΈ // Π° 1000 - ΠΏΡ€ΠΎΠΌΠ΅ΠΆΡƒΡ‚ΠΎΠΊ Π²Ρ€Π΅ΠΌΠ΅Π½ΠΈ соотвСтствСнно 

      I will add a little bit - to remove an interval you need to call clearInterval , for example:

       var someInterval = setInterval("functionName()",1000); // устанавливаСм clearInterval(someInterval); // ΡƒΠ±ΠΈΡ€Π°Π΅ΠΌ 
      • @AlexWindHope correct your mistake. - Michael Nikolaev
      • Ahhh, it means that the function should be written in brackets ... and I wrote without brackets, as a friend recommended to me and nothing worked ... thanks a lot. - Ilya Nikolaev