I’ve created a loop of "changing words" with jQuery
by using the code in this answer:
jQuery: Find word and change every few seconds
How do I stop it after some time? Say after either 60 seconds or after it has gone through the loop?
(function() {
// List your words here:
var words = [
'Lärare',
'Rektor',
'Studievägledare',
'Lärare',
'Skolsyster',
'Lärare',
'Skolpsykolog',
'Administratör'
],
i = 0;
setInterval(function() {
$('#dennaText').fadeOut(function() {
$(this).html(words[i = (i + 1) % words.length]).fadeIn();
});
// 2 seconds
}, 2000);
})();
To stop it after running a set number of times, just add a counter to the interval, then when it reached that number clear it.
e.g.
If you want to stop it after a set time has passed (e.g. 1 minute) you can do: