Currently, I am delving into the world of JavaScript and trying to gain a better understanding of how to manipulate the DOM on my own. Throughout this learning process, I have encountered a puzzling situation that I am seeking assistance with.
The following code snippet represents an example of HTML markup:
<html>
<body>
<h1>A heading</h1>
<div id="myDIV"></div>
<script type="text/javascript" src="thejs.js"></script>
<script type="text/javascript">
document.getElementById("myDIV").innerHTML="<p>Try this one comes from script inside html source</p>"
</script>
</body>
</html>
My expectation is to achieve a similar outcome by using an external JavaScript file that is linked within the script tags. The linked file contains the following code:
document.getElementById("myDIV").innerHTML="<p>While this one comes from a separate JS file</p>";
However, I am facing a roadblock as nothing seems to happen when I run the code. I understand that this issue might appear trivial, and I sincerely apologize for any oversight on my part.