document.getElementById(); returns null on an id that definitely exists : <p>Does anyone know why document.getElementById("closebtn"); returns null? I have tried console.logging it, and i just get null. I am using node.js and Electron</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;link rel="stylesheet" type="text/css" href="home.css" /&gt;
    &lt;script&gt;
    console.log(document.getElementById("closebtn"));&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;div id="menubar"&gt;
        &lt;button id="closebtn" onclick=""&gt;&lt;/button&gt;
    &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
