+ 2
Why this code works within script tag and not in js in code playground??
var obj; obj = document.getElementById("demo"); obj.innerHTML = " Hello";
6 Réponses
+ 5
onload = function(){ //your code here }
+ 5
That is because Sololearn by default links out script in head tag .
And because of that html elements are not loaded, so you can not select them instead you have to wait for them to load.
You have to use onload event described by Mr. Sami Khan
+ 2
could you please link the code here in this question?
+ 2
Okay, i got it now,...
Thank you both Sami Khan and 🔫 Rick Grimes
+ 1
Hmm, Nice explanation 🔫 Rick Grimes , Deep_Blue