hi
I'm looping the array using each function. we are doing some animation kind of thing. we are changing the back ground color of td element in the table.we have array with td elements. if we click on any of the td elements,it loop through that array and start changing the back ground color of the each td in the array.we have 1 stop button ,(pause and start(in the same button)). when i click on stop button, it has stop entirely. when i click on pause, it has to stop then and there, if i again click on start button,it has to start from there.what logic we have written is, we are assigning 1 to Global variable variable, when we click on stop button assigning 0 to that Global variable. in the each loop, kept logic like if Global variable is
global variable is 1 run the loop else break(return false) the loop.only pause is working.
Thanks in advance, if some one helps me.
below are the code details.
function GenrateDecessionLineAnimate1()
{
count=1;
var delay = 100;
var total=DecessionLineAnimateList1.length;
$(DecessionLineAnimateList1).each(function () {
var fnc = function (y) { return function () {
if(count ==1){
$(y).css('background-color', 'red'); $(y).focus() }
else return false;
}} (this)
var fnc2 = function (y) { return function () {
if(count ==1){
$(y).css('background-color', '#efefef'); }
else return false; }} (this)
setTimeout(fnc, delay);
setTimeout(fnc2, delay + 2000);
delay += 2000;
});
on the stop button click event calling the below metod.
var count =1;
function PauseAnimation()
{
if(count == 1)
count=0;
else count=1;
}