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?

14th Jan 2017, 4:32 PM
D G D
D G D - avatar
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 )...
14th Jan 2017, 5:46 PM
visph
visph - avatar
0
@visph thank you!
15th Jan 2017, 10:03 AM
D G D
D G D - avatar