I have a callback function given with a toggle function. The idea is that all the <div> elements will be toggled and I will get one alert message. Now I know I can easily solve this problem with some sort of flag variable (like a boolean to see if this was the first call or not), but I don't want to do it like that if there is a better way.

Here's the jQuery:
$(':submit').click( function() {
    $('div').toggle(slow, function() {
           alert("The divs were all toggled!");
What happens is that I get an alert (one after another) for each <div> element that was toggled (because the toggle function is called on each <div>, and therefore, the call back's alert is called on each <div>). Is there a way to get to call the alert() only once, without using some sort of flag variable?