Reputation: 1814
I'm trying to automate a slider by using following Jquery code
while(true){
setTimeout(function(){
$('.bx-next').click();
}, 3000);
}
but this leads to crash the browser.. Any better way???
Upvotes: 1
Views: 115
Reputation: 24406
If you want an endless loop every 3000 ms, use setInterval
not setTimeout
and get rid of the while(true)
:
setInterval(function() {
$('.bx-next').click();
}, 3000);
Docs: http://www.w3schools.com/jsref/met_win_setinterval.asp
Upvotes: 3