jQuery click() every xxx seconds
I'm trying to trigger a click() function at a set interval.
I have it working apart from the fact that when I minimise the window the clicks "build up". When the window is opened again all of the clicks are triggered in quick succession.
I have spent a few hours on this and have come to understand it's to do with jQuery's animation function and that the way around it is the use queue() to stop the clicks going off a set time apart.
I'm fairly new to jQuery and I don't really understand how to do this though, nothing I try seems to work how I expect. Here is the code i'm using (before attempting to use queue()):
var count = 1;
timer = window.setInterval(autoAdvance, 7000);
count = count + 1;
// Simulating a click on the next slide.
$jQ('.image_thumb ul li.slide-' + count).click();
if(count == slidesCount)
count = 0; // Goes back to the first slide after reaching the last one.
It just simulates a click on a thumbnail, which changes my slider to the next image. slidesCount is a dynamic variable that comes from PHP, it contains a count of how many slides are in the slider.
Does anyone know how I can solve this? Thank you.