I'm trying to make a loop in Javascript/jQuery. This block of code works fine on one run through (if I remove the 'for' loop), but if I put it in a loop it doesn't appear to work once and instead seems to hang.
var z=0;
for(z=0;z<=1000;z++){
$("#welcome").fadeTo(100,0.1,
function(){$("#welcome").fadeTo(100,1.0,
function(){$("#welcome").fadeTo(50,0.1,
function(){$("#welcome").fadeTo(10,1.0,
function(){$("#welcome").fadeTo(10,0.1,
function(){$("#welcome").fadeTo(10,1.0,
function(){$("#welcome").fadeTo(1,0.0,
function(){$("#welcome_distort").fadeTo(1,1.0,
function(){$("#welcome_distort").fadeTo(500,1.0,
function(){$("#welcome_distort").fadeTo(1,0.0,
function(){$("#welcome").fadeTo(1,1.0,
function(){$("#welcome").fadeTo(50,0.1,
function(){$("#welcome").fadeTo(50,1.0,
function(){$("#welcome").fadeTo(500,1.0
);}
);}
);}
);}
);}
);}
);}
);}
);}
);}
);}
);}
);}
);
}
Not the clearest explanation, I know, but any help (including advice with javascript loops) would be much appreciated.