I'm aware of both setInterval
and setTimeout
functions but it's not suitable for my case, because I need to create an img
DOM element in the interval of 7 seconds.
- The count of images are not predefined (varies daily).
When I use setInterval
, I cannot completely stop it after certain limit (daily count). [clearInterval
clears iterations only]
When I use setTimeout
inside loop (daily count), it never delays. So the only possibility is a sleep function. Can anyone help for this situation?
- What's the best way to implement a sleep function JavaScript?