+ 1
JavaScript Error in Sololearn but Not in PC
var item = document.getElementById('item'); item.onclick = function () { //some code } This code is working perfectly in my PC browser but I'm getting error in SoloLearn on line where I set on click https://code.sololearn.com/WU08tvIgXv53/?ref=app
1 Answer
+ 11
No worry your code is fine and the problem occurs due to the way SoloLearn execute the Web code.
The error was thrown as the JS get executed first before the DOM was loaded. Therefore you can try to place the scripts near the end of body and you're good to go. đ
đĄ Reference
https://code.sololearn.com/WXe61FrE4YD4/?ref=app