Issue
In the below code , say if i want to change the color of the cell 1 ,2 and 4 , then they change the color at different intervals. (say first 1 changes then 2 changes then 4 changes)
I want all of them (1,2 and 4) to change the color at the same time.
That will look like all (1,2 and 4) are red , then all the 3 are blue again.
Here temp_array will have the cells that i have to change the color (say temp_array will have 1,2 and 4.
function startChangingColor()
{
var temp;
for(var i=0;i<temp_array.length;i++)
{
temp = temp_array[i];
intervalid[i] = setInterval( createCB(temp) ,300);
}
}
function createCB( val )
{
return function()
{
changeColor( val );
};
}
var flag = true;
function changeColor (element)
{
if(flag==true)
{
document.getElementById(CELL+element).className='redled';
flag=false;
}
else if (flag==false)
{
document.getElementById(CELL+element).className='grayled';
flag = true;
}
}
Don’t know if I’m reading this correctly but try this:
demo: http://jsfiddle.net/NZPTE/3/