This is my script.js
document.addEventListener("DOMContentLoaded", function() {
// this function runs when the DOM is ready, i.e. when the document has been parsed
var elem = document.getElementById("output");
elem.innerHTML = 123;
});
<h1>Hello!</h1>
<div id="output">11</div>
When I load index.html in the browser, I don't see a 123 displayed. Why so ?
Original HTML
<!DOCTYPE html>
<html>
<head>
<title>My page</title>
<script async type="text/javascript" src="script.js"></script>
</head>
<body>
<h1>Hello!</h1>
<div id="output">11</div>
</body>
</html>