Jquery Prepend: Cannot call method 'createDocumentFragment' of null
<p>During page startup I'm trying to add an element to the DOM.</p>

<p>I have the following code:</p>

<pre><code>$(document).ready(function () {
    $(document).prepend("&lt;div id=new_div style=z-index:1;&gt;&lt;/div&gt;");
});
</code></pre>

<p>I've tested this on FF21, Chrome27 and IE10. They all return the error mentioned in the title (exact wording is from the Chrome debugger).</p>

<p>Debugging on jquery-1.10.0.js, I tracked down the problem to line 5998 where</p>

<pre><code>safeFrag = document.createDocumentFragment()
</code></pre>

<p>Apparently document is null. Going up the stack trace to <code>domManip</code> on line 6249 the object is passed as <code>this[ 0 ].ownerDocument</code>, which is null.</p>

<p>I've stripped the javascript on the page to just loading jQuery and running this command, and the issue persists.</p>

<p>See <a href="http://jsfiddle.net/jnfsmile/LWd6S/" rel="nofollow">this jsFiddle</a>, the alert doesn't pop, meaning the javascript engine got stuck on the line before.</p>

<p>Help appreciated.</p>
