The code of the first function shows three different divs on specific Interval 5seconds (div1,div2,div3).
The code of the second function used to stop showing the divs.
while showing div2 , I clicked the link to stop at that point it got stopped.
But after that i clicked it again and it shows div1 (its getting toggling fine) but i would like to continue next action which was to show div3.
Jquery Code :
$(function() {
var IntervalId;
function first_function() {
var counter = 0,
divs = $('#div1,#div2,#div3');
function showDiv () {
divs.hide() // hide all divs
.filter(function (index) { return index == counter % 3; })
.show('fast'); // and show it
counter++;
};
showDiv();
IntervalId = setInterval(showDiv, 5000);
};
function second_function(){
clearInterval(IntervalId);
}
$("#link1").toggle(
first_function,second_function
);
});
Html Code :
<a href="javascript:void(0);" id="link1">Toggle</a>