I am new to coding and am trying to build a very basic website with html, css and js.
When referring to code in the html file from js, I encounter an issue.
My HTML file contains the following code:
<!DOCTYPE html>
<html>
<head>
<title>random stuff</title>
<script src="Mgen.js"> </script>
</head>
<body>
<p id="quote"> quote </p>
</body>
</html>
Mgen.js in src="Mgen.js" is a hyperlink that links to the correct js file, which file is stored in the same folder as the HTML file.
In Mgen.js I have included the following code to test the connection between the files:
let quote = document.getElementById('quote')
console.log(quote)
This gives the following error message:
Uncaught ReferenceError ReferenceError: document is not defined
at <anonymous> (undefined:1:13)
at Module._compile (undefined:1105:14)
at Module._extensions..js (undefined:1159:10)
at Module.load (undefined:981:32)
at Module._load (undefined:822:12)
at executeUserEntryPoint (undefined:77:12)
at <anonymous> (undefined:17:47)
I have installed node.js and enabled and disabled auto-attach. I have also tried checking the code through a browser, here too no elements of the js file show (I tried this with different js code that should be shown in a browser if functional).
