Manipulating <body> with jQuery? (Or figuring a better solution)
<p>I'm trying to create a JS-script to make modifications to add a footer to HTML -documents on the fly. The idea is to append a div-element at the end of the document to contain the footer, and to provide a floating fixed footer, I also need to have all of the other content wrapped in a div, basically I need something like this:</p>

<pre><code>&lt;html&gt;
 &lt;head&gt;
  &lt;title&gt;Foobar&lt;/title&gt;
 &lt;/head&gt;
 &lt;body&gt;
  &lt;div id="contentWrapper"&gt;
    &lt;!-- Content is here --&gt;
  &lt;/div&gt;
  &lt;div id="footerWrapper"&gt;
    &lt;!-- Footer goes here --&gt;
  &lt;/div&gt;
 &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>The problem is, that the HTML is generated from a system where the end user's have had a little too much control over the structure (it's a blogging platform), and there's no guarantee of a certain sturcture hence I need to wrap the content in a div to ensure the footer works ok.</p>

<p>What I tried, and realized that doesn't work is:</p>

<pre><code>$(document.body).wrap($('&lt;div/&gt;').attr('id','footerWrapper'));
</code></pre>

<p>The problem with this is that due to the fact that the HTML structure is generated by the user, I have been forced to inject links to the JS-file inside the <code>&lt;body&gt;</code>-tag. So now when I call wrap(), it seems that everything is first removed from $(document.body) and then appended in the new div. Since the JS-files are linked from inside , calling wrap() seems to remove them momentarily, and it seems that the scripts are unloaded by the browser and everything stops working and I'm left with a blank page. Not exactly what I had in mind.</p>

<p>Next idea was to first copy the JS-tags to the head-element to preserve them, so I wrapped them in a div (yeah, ugly, I know), and tried to copy them to the :</p>

<pre><code>$(document.head).append($('#copyToHead').html());
</code></pre>

<p>That didn't do anything, and seems that $(document.head) isn't usable with functions such as .html() and .append().</p>

<p>So, now I'm out of ideas. Anyone have any ideas?</p>
