[jQuery] Re: There must be a better way to write this

2008-10-02 Thread Pappa Bear
You could try something like this without the timers. It's a script I wrote for a sidebar, but it handles the fade no matter which direction you travel (was meant for an automated fade->to->next sidebar). I will have to check the nth-child to see if it would fit my own scenario if you feel it oper

[jQuery] Re: There must be a better way to write this

2008-10-01 Thread ferdjuan
Erik and Josh, Excellent suggestions, I forget about callback functions from time to time and though both of your suggestions worked as desired, the effect was not the correct speed, also I wanted to reverse the order of the fadeouts. I struggled with this for about 30 minutes, made the post, the

[jQuery] Re: There must be a better way to write this

2008-10-01 Thread Josh Nathanson
Hey ferdjuan, give this a whirl - this will work with any number of children. var kid = $("#folio").children(), index = 0, numelements = kid.length; function fadeEmOut( index ) { if ( index <= numelements ) { kid.eq( index ).fadeOut( function() { return fadeEmOut( ++index ) }); } } fadeE

[jQuery] Re: There must be a better way to write this

2008-10-01 Thread Erik Beeson
How about a self calling anonymous function: $('#folio > :first').fadeOut(function() { $(this).next().fadeOut(arguments.callee); }); Or if you're uncomfortable with that syntax, just make a function for it: function fadeNext() { $(this).next().fadeOut(fadeNext); } $('#folio > :first').fadeOu