0
Loading problem with the playground
You can't use window.onload to get some values(eg. let x = document.getElementById("id"); )and use it later on. Since its local variable. You can't even make the script load at the end since its not external. I needed to get some divs and use them later but it was showing error since the html didn't load. Is there any way to solve this problem?
4 Respostas
+ 3
declare you variable globally
var x;
window.onload =function(){
x = document.getElementById("test");
x.style.color = "red";
}
+ 2
Didn’t load? onload is not executed?
0
Check this-
https://code.sololearn.com/W1dxqG96oFw7/?ref=app
0
😂😂I'm so stupid. Thanks Toni Isotalo.