0
Why this error?
I am trying since yesterday but it's not working I have no idea what's wrong in this code why iam getting error of null? https://code.sololearn.com/WM5n3x9ExE6o/?ref=app
4 Réponses
+ 4
Javascript is getting executed before html dom loads because sololearn places javascript files inside head tag which means there is no button element yet and so trying to get it and performing some operation on it gives you an error .
Simply place your js code (dom interaction one) inside the onload function which will execute js code only after html dom is loaded.
onload=()=>{
}
+ 3
You script ran before your html was loaded
Have a look on this
https://code.sololearn.com/WrHklCptM0m2/?ref=app
+ 3
https://code.sololearn.com/W1gDjWO5ZvJB/?ref=app
+ 1
Thank you very much everyone for resolving my issue❤️