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
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="home.css" />
<script>
console.log(document.getElementById("closebtn"));</script>
</head>
<body>
<div id="menubar">
<button id="closebtn" onclick=""></button>
</div>
</body>
</html>
`. The DOM needs to load before you can access it with the code.
– Andy Jan 18 '19 at 13:05