0
Whay js can not set property .innerHTML?
9 Respuestas
+ 14
It can.
Can you provide your code?
+ 11
The error probably occurs because the DOM hasn't loaded when he attempts to access it. Donna placed the code at bottom, so it guaranteed it's loaded.
+ 2
thanks Donna☺
+ 2
ohhh....I didnt noticed script tag..i just noticed those two getElementById code
+ 1
document.getElementById('new').innerHTML="hello";
+ 1
yes
0
Does these two codes make different execution(i mean both are right so why did the first code gave error
document.getElementById('new').innerHTML="hello";
------and--------
var x=document.getElementById('new');
x.innerHTML="hello";