+ 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

17th Jan 2018, 3:06 PM
Ravindra Sisodia
Ravindra Sisodia - avatar
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
17th Jan 2018, 3:20 PM
Zephyr Koo
Zephyr Koo - avatar