getElementById(...) is null ? why? : <p>Check this code please, and help me solve why i'm getting type error <em>document.getElementById(...) is null</em></p>

<pre><code>function Dropdown(){
    this.core = ['NIS', 'EUR', 'USD'];
    this.check = function(){
        var cho = '&lt;select&gt;';
        for(x in this.core){ 
            cho += '&lt;option value="'+ this.core[x] +'"&gt;'+ this.core[x] +'&lt;/option&gt;';
        }
        cho += '&lt;/select&gt;';
        return cho
    };

}

var obj = new Dropdown();
document.getElementById("demo").innerHTML = obj.check();
</code></pre>

<p>on HTML file i have : </p>

<pre><code>  &lt;div id="demo"&gt;Check Console log&lt;/div&gt;
</code></pre>

<p>Thank you for any help.</p>
