For your information, this is not a duplicate - my question was not solved by similar questions .
I am trying to log this element:
<p id="one">Test</p>
to the console with JavaScript:
var one = document.getElementById("one");
console.log(one);
However, this returns null
for the console.log(one);
line, and I can't figure out the reason. Where is the null
value coming from, and how do I make it reference the <p id="one">Test</p>
element?
EDIT: Full HTML code:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>A tester</title>
<script src="index.js"></script>
</head>
<body>
<p id="one">One</p>
</body>
</html>