0

Sincerely I didn't know how to write the title. I need to click in a link of each "li" item but every 5 seconds.

I've tried this way:

$("li.li-item").each(function() {
  $(this).find("a").click();
  // here any solution provided in this post: http://stackoverflow.com/questions/14226803/javascript-wait-5-seconds-before-executing-next-line
});

but it does not work.

FlamingMoe
  • 2,709
  • 5
  • 39
  • 64

1 Answers1

0

Sorry Set Sail Media, but as I explained you it does not work, since I need each link to be click every 5 seconds ... but I did the trick based on what you wrote:

function liLoop() { 
   if ($("li.li-item:not(.done):first").length == 0) {    
      clearInterval(loopInterval); 
   } 
   $("li.li-item:not(.done):first").find("a").click(); 
   $("li.li-item:not(.done):first").addClass("done"); 
} 
var loopInterval = setInterval(function(){ liLoop() }, 5000);
FlamingMoe
  • 2,709
  • 5
  • 39
  • 64