How to initialize firstChild so I don't get "x.firstChild is null or not an object"?
<p>In my JSP/HTML I have this:</p>

<pre><code>&lt;div id="exampleLabel"&gt; &lt;/div&gt;
</code></pre>

<p>Then in my javascript section I have a function called from an onclick like this;<br></p>

<pre><code>function changeLabel(){
    exampleLabel.firstChild.nodeValue = 'LABEL HAS CHANGED';
}
</code></pre>

<p>This works fine in Chrome, does nothing in Firefox and in IE an error on page appears saying </p>

<blockquote>
  <p>exampleLabel.firstChild is null or not an object.</p>
</blockquote>

<p>Ok I can take it that there was no firstChild so trying to do firstChild.ANYTHING would be a NPE, I can even take it that the other browsers don't just initialize it themselves like Chrome obviously does.</p>

<p>Question is, how do I initialize it myself so I can then go <code>.nodeValue = "blahblah"</code> on it?</p>
