title: jQuery event handlers always execute in order they were bound - any way around this?
body: <p>It can be anoying that jQuery event handlers always execute in the order they were bound. For example:</p>
  
  <pre><code>$('span').click(doStuff1);
  $('span').click(doStuff2);
  </code></pre>
  
  <p>clicking on the span will cause <code>doStuff1()</code> to fire, followed by <code>doStuff2()</code>.</p>
  
  <p>At the time I bind doStuff2(), I would like the option to bind it <strong><em>before</em></strong> doStuff1(), but there doesn't appear to be any easy way to do this.</p>
  
  <p>I suppose most people would say, just write the code like this:</p>
  
  <pre><code>$('span').click(function (){
      doStuff2();
      doStuff1();
  });
  </code></pre>
  
  <p>But this is just a simple example - in practise it is not always convienient to do that.</p>
  
  <p>There are situations when you want to bind an event, and the object you are binding to already has events. And in this case you may simply want the new event to fire before any other existing events.</p>
  
  <p>So what is the best way to achieve this in jQuery?</p>