Make jQuery wait for one .each function to complete before next line is executed?

I have this:

$  ("a.fadeout").click(function(event){
    event.preventDefault();
    var loc = this.href;

    //Do this first...
    $  ($  (".faded").get().reverse()).each(function(i) {
        $  (this).delay(i * 100).fadeOut();
    });

    //And only then do this..
    window.location = loc;

});

How do I force the fadeouts to complete before the location changes? If it was just one fadeOut() I would use it’s callback, but as there are many, I can’t work out how to do it.

Cheers!
Ben

newest questions tagged jquery – Stack Overflow

About Admin