Hello everyone. )
There is a certain JS Code:
scripts.js
mysite={ addDiv: function() { var newDiv=document.createElement("div"); var div=document.getElementById("myDiv"); div.appendChild(newDiv); } }
why in that case nothing works: somepage.html:
.... <script> mysite.addDiv(); </script> <body> ... <div id="myDiv"></div>
And in this, everything works:
....
<body onload="mysite.addDiv()"> ... <div id="myDiv"></div>