I have been trying to replace the innerHTML
of an elemnent in Javascript using document.getElementbyId(id)
, but for some reason i get null
.
Here's the html file:
<body id="main">
<p>Hello World!</p>
</body>
And here's the JavaScript:
var b = document.getElementById("main");
b.innerHTML = "World Hello!";
And here's the error:
Uncaught TypeError: Cannot set property 'innerHTML' of null
at about.js:2
NOTE: the name of js file is about.js, which i have referenced to the html file