jQuery window resize prepend
<p>Having a problem with window resize. What I'm trying to do is check whether the window is less than 600 pixels, then prepend a div (.inner) to the body. On resize, I want to check the window width and if it's greater than 600 pixels, put the div (inner) back in its place.</p>

<p>HTML</p>

<pre><code>&lt;body&gt;
  &lt;div class="outer"&gt;
     &lt;div class="inner"&gt;
     &lt;/div&gt;
  &lt;/div&gt;
</code></pre>

<p>JS</p>

<pre><code>var windowWidth = $(window).width();

checkWidth();

function checkWidth(){
    if(windowWidth &gt; 600){
    $('.outer').append($('.inner'));
    console.log('back in place');
  } else {
    $('body').prepend($('.inner'));
        console.log('prepend');
  }
}
$(window).resize(function() {
  checkWidth();
}).trigger('resize');
</code></pre>
