0

JavaScript returns an error when using innerHTML

Here is the code link, https://code.sololearn.com/WLAIVQWs20NM/?ref=app

28th Aug 2019, 11:29 AM
Bia
Bia - avatar
2 Respostas
+ 2
On sololearn, the page has to load before accessing it with JavaScript. So instead of: var elem = document.getElementById("test"); Do: var elem; window.onload = function() { elem = document.getElementById("test"); }
28th Aug 2019, 11:34 AM
Daniel C
Daniel C - avatar
0
Thanks, it works very okkkey
28th Aug 2019, 11:47 AM
Bia
Bia - avatar