How do i make this code work with an external javascript file?
<!DOCTYPE html>
<html>
<body>
<h2>My First Page</h2>
<p id="demo"></p>
<script>
var elem = document.getElementById("demo");
elem.innerHTML = "Hello World!";
</script>
</body>
</html>
If i try to write this inside script.js file it will return this error: "TypeError: elem is null"
OBS: I have no problems running this as inner HTML, just the external part is getting me.
` tag
– Muhammad Usman May 18 '18 at 20:57