Adding some delay in an recursive loop and breaking out of it on mouseover
Posted
by Moak
on Stack Overflow
See other posts from Stack Overflow
or by Moak
Published on 2010-06-09T02:58:12Z
Indexed on
2010/06/09
3:02 UTC
Read the original article
Hit count: 240
I have created a loop
function loopThem(){
$$('#main-nav a').each(function(i, n) {
i.up("#main-nav").down("li.active").removeClassName("active");
i.up("li").addClassName("active");
var target = i.readAttribute("href");
i.up(".home-top").down("li.visible").removeClassName("visible");
i.up(".home-top").down(target).addClassName("visible");
});
loopThem();
}
This function is called when the dom is loaded
document.observe("dom:loaded", function() {
loopThem();
});
It does what I want as far as rotating through a set of banners, however it does so at light speed
How Can I
A add a delay between the changing?
B stop the loop from continuing once I mouse over?
© Stack Overflow or respective owner