title: JQuery: Append before an element
body: <p>Using JQuery I have appended a div into a container called <code>.mobile-sub</code>. I call the append by doing:</p>
  
  <pre><code>$('.s2_error').addClass("revive");
  $('.revive').parent(".mobile-sub").append('&lt;div&gt;mydiv&lt;/div&gt;');
  </code></pre>
  
  <p>It works fine but the problem is that it is placing the div <strong>after</strong> the <code>.s2_error</code> tag whereas I need it to be placed <strong>before</strong> so the end result HTML will look like this:</p>
  
  <pre><code>&lt;div&gt;mydiv&lt;/div&gt;
  &lt;p class="s2_error"&gt;Error&lt;/p&gt;
  </code></pre>
  
  <p>Any ideas?</p>