+ 1
Everything seems to be correct but still something strange happened
Here's my code, i don't understand what is wrong here as everything seems perfect but still it's giving an error https://code.sololearn.com/W7bk3uyXlTKu/?ref=app Is it really my mistake or something else, please reply me as soon as possible. Thank You for spending your precious time here
4 Respostas
+ 2
You have to wrap the part where you try and get from the document inside the onload function, it may just be simpler to wrap everything in it, but technically you don't have to as long as you don't use the variable before it is defined.
+ 1
The javascript gets run before the DOM loads. To fix this error, you can just wrap the javascript in a function and add an "onload" listener to the window:
window.onload = () => {
// ...
};
+ 1
Brian R Thx it helped
0
Brian R i have to wrap whole function inside this window.onload right?