Continue iteration until button Stop is clicked
I have a div showing letters one at a time.
- var abcdef = ["A", "B", "C", "D", "E", "F"];
- var time = 500;
- jQuery.each(abc, function(i, item) {
- setTimeout( function(){ $("#container").empty().append(item); }, time)
- time += 10000;
- });
- <div id="container"></div>
- <input type="button" value="Start" />
- <input type="button" value="Stop" />
So all the letters is shown one by one but only but only one round. I need the each loop to continue until I press button "Stop". Then when pressing "Start", then I would want the each function to continue again.