0
Bug?
I have made a code that works fine in SPCK editor, but upon copy and pasting it here fails to work. Is this a problem with the application? https://code.sololearn.com/WB8sPzpXWeo3/?ref=app
1 Antwort
+ 3
Code Playground loads the code in JS section as if it was a script imported in <head> section of HTML document. As such, the DOM isn't yet completely loaded, thus the error message came for an attempt of referencing a non existing element.
Wrap your code inside "load" event handler as follows (in JS section)
window.onload = function()
{
// your JS code here
}
For a comprehensive explanation on why this happens, please read this post 👇
https://www.sololearn.com/post/90825/?ref=app