Search code examples
jquerytimeoutdelayeach

Jquery timeout on each


I'm trying to write a jQuery function to change out href of a link, but I'm not quite sure how to do it. I've implemented a slider, but I have a link which lives outside of the slider (outsideLink) which needs to change as the slider changes.

I'm trying to achieve the following:

for each link in sliderList
     get currentLink.href
     outsideLink.href = currentLink.href
     wait 3 seconds
     repeat
end

I'm not sure how to implement the delay when I'm going through a list of items though.


Solution

  • I'd approach this a bit different, just update it when the slider changes like this:

    $('.selector').slider({
      slide: function(event, ui) {
       //outsideLink.href = currentLink.href
      }
    });
    

    You can see a full list of slider events here