0

I need help finding the root of the problem. When I fix one error another one pops up like a chain reaction. What's the cause???

https://code.sololearn.com/Wpf5z4Kmd9x3/?ref=app

10th Aug 2020, 1:45 AM
Grethif
Grethif - avatar
3 Antworten
+ 4
Your javascript will run before the document is loaded, so all the `.getElementById` calls return null. You need to wrap your entire code in one of these: window.addEventListener("DOMContentLoaded", () => { // code goes here ... });
10th Aug 2020, 2:03 AM
Schindlabua
Schindlabua - avatar
+ 3
Problem fixed ! https://code.sololearn.com/Wvo4BhpPESlF/?ref=app Problem fix detail : I putted your whole JS code inside window.onload = function (){ //Your code } It make ur JS to run after the DOMs setup Without it the JS code run before the DOMs setups in ur page and not able to get the wbtn id from Dom So easy
10th Aug 2020, 2:03 AM
Abhay
Abhay - avatar
+ 1
Thanks Schindlabua, Abhay. Curious thing is that the code works perfectly on another editor but SL had an issue with it, anyway I'm glad its a simple fix
10th Aug 2020, 10:14 AM
Grethif
Grethif - avatar