[jQuery] Questions on animate's callback

[jQuery] Questions on animate's callback


I have two questions about animate.
1) Animate's callback is called once for every element matched
against. What's the proper way to handle a situation where you want
some code to run only once when all matched elements' animations have
finished? In pseduocode:
$("this matches 4 elements").animate({
opacity: 0
}, "slow", function() {
// run this code only one time after all 4 matched elements have
finished fading out
});
2) In what situations would you use animate's callback vs. queue/
dequeue and vice versa? They seem kind of interchangeable to me in
terms of using them to create a synchronous chain of events. Another
pseduocode example:
Why do this:
$("element").animate({
property: value
}, "speed", function() {
// do this when animation finishes
});
vs. this:
$("element").animate({
property: value
}, "speed")
.queue(function() {
// do this when animation finishes
$(this).dequeue();
});
Thanks in advance for any insight anyone can provide. :)