+ 1

Cannot set propety 'innerHTML' of null

I want to make a test: var elem = document.getElementById("A"); elem.innerHTML = "Hello"; But it is marking a Error at Line 2 Why? I put: <body><div id="A"></div></body>

25th Mar 2017, 7:24 PM
Santiago Pacheco
Santiago Pacheco - avatar
1 Antwort
+ 3
window.onload= function (){ your code }
25th Mar 2017, 7:28 PM
Yaroslav Pieskov
Yaroslav Pieskov - avatar