Hi everyone, I have multiple setTimeout functions like this:
function bigtomedium(visiblespan) {
visiblespan.removeClass('big').addClass('medium');
setTimeout(function(){ mediumtosmall(visiblespan);},150);
};
function mediumtosmall(visiblespan) {
visiblespan.removeClass('medium').addClass('small');
setTimeout(function() { smalltomedium(visiblespan); },150);
};
function smalltomedium(visiblespan) {
visiblespan.removeClass('small').addClass('medium');
setTimeout(function() { mediumtobig(visiblespan); },150);
};
function mediumtobig(visiblespan) {
visiblespan.removeClass('medium').addClass('big');
setTimeout(function() { bigtomedium(visiblespan); },150);
};
Which is activated in jquery onclick:
$('div.click').click(
function(event) {
var visiblespan = $('span:visible');
mediumtosmall(visiblespan);
}
);
What I need to do, is to get the click to hide invisible span as well.
$('div.click').click(
function(event) {
var visiblespan = $('span:visible');
var invisiblespan = $('span:not(:visible)');
mediumtosmall(visiblespan);
clearTimeout(invisiblespan);
}
);
What I'm not sure how to do is to write the clearTimeout function that will stop the loop. Any help is greatly appreciated. Thanks.