+ 5
why is this throwing an error in js? var output =document.querySelector("#output"); output.innerHTML="Hello world"; reference error of output.innerHTML null line 2
4 Réponses
+ 4
declare this script code inside body ,otherwise declare this code inside window.onload=function(){}
link:http://www.sololearn.com/app/javascript/playground/WrbhZ0C6NDmm/
+ 1
the window.onload=function (){ some code} works.
I Don' t understand the declaration in body though. do you mean dumping the js script in the html body part?
+ 1
yes correct as your are accessing Id from html code so the script code should run after the dom elements loaded
+ 1
thanks very much for your help Moorthi