What is wrong with this code? $(document).ready(function() { var a = $("#job-banner-content div"); if (a.length > 0) { var i = 0; var f = function() { i += Math.max(1, Math.floor(Math.random() * (a.length - 1))); var b = a.eq(i % a.length).css("top", "-200px").animate ({ top: "0px" }, 2000); setTimeout(function() { b.animate({ top: "200px" }, 2000); }, 7000); } f(); setInterval(f, 10000); } });
What happens is that the animation only occurs occasionaly every 10 sec not every time with 10 sec intervals. I can't wrap my head around this, but then, I'm new to jQuery am I doing something wrong here?