I have a link that changes text every time its clicked but I am trying to find a way for it to automatically switch to the next variable after a period of time, sort of like a rotator.
This is what I have:
$(document).ready( function() {
var quotes = [
'Link 1',
'Link 2',
'Link 3',
'Link 4',
'Link 5',
'Link 6'
];
function loadQuote(i) {
return quotes[i];
}
function randNumber() {
return Math.floor( Math.random() * quotes.length );
}
$('#button-reload').click(function() {
$(this).html(loadQuote(randNumber()));
});
$('#button-reload').html(loadQuote(randNumber()));
});
and here is a jsfiddle
any ideas?
1 Answer