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
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
|