Why – Matt Ellen Aug 05 '19 at 12:02

1 Answers1

3

It does, but your script is executed before your DOM is loaded properly. Use

window.onload = function() {
    document.getElementById("demo").innerHTML = "Hello, World!";
}

Also it's possible to use the onload attribute:

<body onload="jsFunction()"></body>
Alphastrick
  • 131
  • 1
  • 9