Using jQuery I would like to loop through an array of links and load the contents of each link into a DIV after a set interval. For example, if I have my parent page "parent.html" and an array of links - "test1.html, test2.html and test3.html" I would like to initially load test1.html into a div within parent.html and then after a set interval replace test1.html with test2.html and then test3.html repeating the process indefinitely.
I would really appreciate if someone could help me out. I have tried using .get() and also setTimeout() but just don't have the expertise and experience to put this all together. Any help would be very welcome.
Thank you.
This will switch every 2 seconds (2000 milliseconds). Test online at http://jsbin.com/owoxo
--
This will do what you want.
You can view a working demo here. It only loads each link once, then caches the result. Subsequent iterations simply pull from the cache.
HTML
I would assume the requirement is to load the content of the linked page, not just the link href? Here's the one based on Jonathan's.
DOM manipulation is expensive. Try not to do it if you can avoid it.
Are the links you're loading static or dynamic? Meaning once loaded do you need to load them again? If the answer is no then do this:
with CSS:
and:
This way you only load the pages once and just hide/show divs as needed to rotate through them.