use of jquery next() in this queue function
<p>I was reading about jquery <code>queue()</code> <a href="http://stackoverflow.com/a/3314877/1252748">here</a>. The first answer is pretty comprehensive:</p>

<pre><code>var theQueue = $({}); // jQuery on an empty object - a perfect queue holder

$.each([1,2,3],function(i, num) {
  // lets add some really simple functions to a queue:
  theQueue.queue('alerts', function(next) { 
    // show something, and if they hit "yes", run the next function.
    if (confirm('index:'+i+' = '+num+'\nRun the next function?')) {
      next();
    }
  }); 
});

// create a button to run the queue:
$("&lt;button&gt;", {
  text: 'Run Queue', 
  click: function() { 
    theQueue.dequeue('alerts'); 
  }
}).appendTo('body');

// create a button to show the length:
$("&lt;button&gt;", {
  text: 'Show Length', 
  click: function() { 
    alert(theQueue.queue('alerts').length); 
  }
}).appendTo('body');
</code></pre>

<p><a href="http://jsfiddle.net/mkBJk/" rel="nofollow">jsfiddle</a></p>

<p>I can't understand how <code>next()</code> (line 8) is working however. I get that if I comment it out the "next" confirm box fails to pop up until I press the button again, but I thought <code>next()</code> was used primarily for traversing the dom. Here though, it seems like it's telling the function to run again. </p>

<p>Also, if the queuing of the <code>confirm</code> boxes is within the <code>each()</code> function, why would they all be queued successfully without the <code>next()</code>?</p>
