0
simple code works elsewhere but not on sololearn...
Here's my code on SL does not work https://code.sololearn.com/Wqa7Te4g5n4z/#html it complains ```JavaScript Console Uncaught TypeError: Cannot set property 'innerHTML' of undefined Line: 9``` but the same code works here without errors http://codepen.io/pleabargain/pen/egzoyP Why?
2 ответов
+ 2
Wrap your code inside the window.onload event:
window.onload=function() {
/* your code */
};
The JS tab in code playground is loaded/parsed/executed before the Html Dom tree is ready, so you need to wait for it for running your code ( or put it in <script> tag, at the end of the <body> content )...
0
@visph thank you!