<!DOCTYPE html>
<html>
<body>
<script>
var aMessage = document.getElementById("aaa").innerHTML;
console.log(aMessage);
</script>
<p id="aaa">Hello World!</p>
</body>
</html>
When I access the document, the console error I am getting is:
Uncaught TypeError: Cannot read property 'innerHTML' of null
What am I missing?
` element is not yet part of the DOM.
– Pointy Feb 04 '15 at 17:06