That's pretty useful Balazs, for some reason I couldn't get it to
worked though.
I saved your plugin bit that appears in that link in a file and named
it jquery.asynceach.js and linked it
to the page. Anyway, I'll play around with it a little more to see
where the problem is.
Thanks again
On Jan
I've actually made a bit nicer abstraction as a jQuery plugin a while
ago, I think it's much more useful for such things, I almost forgot
about it: http://jsbin.com/unini/edit
This is how your code looks like with it:
$("#container :first-child").asyncEach(function(){
$(this).fadeIn('slow');
}
Thank you so much for the reply. I had figured it out but your way is
much more elegant. here's what I had done:
$(".box").hide();
var currentBox = $("#container :first-child");
fadeMyBoxes(currentBox);
function fadeMyBoxes(thisbox){
thisbox.fadeIn('slow');
It can be done with setInterval too but doing it recursively with
setTimeout is a bit better:
var i=0, elements=$('.box'), length=elements.length;
function fade(delay){
elements.eq(i++).fadeOut();
if(i<=length)
setTimeout(arguments.callee, delay);
//arguments.callee is a reference
> So I think I need to use setTimeout and some kind of a recursive
> method, but I'm not very good with JS so I was hoping someone would
> find this trivial and could help answer my question.
Yes, using setTimeout in a loop would be the way to go. How about
posting the code that you're strugglin
5 matches
Mail list logo