Remove mysterious <TextNode textContent="\n "> with javaScript
<p>I've got a div with two children, one <code>&lt;h2&gt;</code> and one <code>&lt;ul&gt;</code>. </p>

<p>My problem is that when I check .length of my div, by doing <code>document.getElementById('wrap').childNodes.length</code>, I get 5 instead of 2. And if I run <code>console.log</code> on <code>childNodes</code> I get this:</p>

<pre><code>[&lt;TextNode textContent="\n "&gt;, h2, &lt;TextNode textContent="\n "&gt;, ul, &lt;TextNode textContent="\n "&gt;]
</code></pre>

<p>My HTML looks like this:</p>

<pre><code>&lt;div id="wrap"&gt;
    &lt;h2&gt;Lorem&lt;/h2&gt;
    &lt;ul&gt;
        &lt;li&gt;Lorem&lt;/li&gt;
        &lt;li&gt;Ipsum&lt;/li&gt;
    &lt;/ul&gt;
&lt;/div&gt;
</code></pre>

<p>Indenting my code has never before affected the length of the childNodes. </p>

<p>If I type everything on one row (as one long word) I get rid of all <code>&lt;TextNode&gt;</code> and it counts to 2 as it should and not 5. </p>

<p>I've got no idea what's wrong, but I figured I need to remove all empty textnodes. 
Which way would be the best to do this?</p>

<p>Thanks heaps </p>

<p>Ps. These <code>&lt;TextNode textContent="\n "&gt;</code> occurs all over the document, so I need to remove them all, not only in this particular div.</p>
