So the second hidenext(jq) is a function to call itself again if jq.slice(1) still has any elements left?
How do I make a loop of this so it runs indefinitely?
I tried using setInterval but it doesn't work.
EDIT: Okay maybe I used it incorrectly, but now it works
This is my current implementation that relies on the code I mentioned + setInterval to call it every 30seconds. The additional 500ms is a headroom for any possible delay (not sure whether I need it, but I just like to be safe).
However, there is sometimes a bug where it'll display more than one tweet, which is very odd. I still can't find the exact problem. It might have something to do with setInterval not running correctly when there is no window focus on it in Google Chrome.
- var jq = $j('#twitter-3 .tweets li');
- function showt(jq){
- jq.eq(0).fadeIn(500).delay(5000).fadeOut(500, function(){
- (jq=jq.slice(1)).length && showt(jq);
- });
- };
- showt(jq);
- setInterval(function() {
- showt(jq);
- },30500);