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>