Is there a way to make some JS code be executed every 60 seconds? I'm thinking it might be possible with a while
loop, but is there a neater solution? JQuery welcome, as always.
This question is related to
javascript
jquery
html
You could use setInterval
for this.
<script type="text/javascript">
function myFunction () {
console.log('Executed!');
}
var interval = setInterval(function () { myFunction(); }, 60000);
</script>
Disable the timer by setting clearInterval(interval)
.
See this Fiddle: http://jsfiddle.net/p6NJt/2/
Source: Stackoverflow.com