0

Javascript code showing error

Hi there, I am facing a weird problem here. I have been learning responsive web design and JS DOM manipulation and practising it. This code works fine on chrome, codepen or even sololearn when I run it on my laptop. But the moment I run it on my phone, It throws an error which reads "Uncaught TypeError: Cannot read property 'addEventListener' of undefined Line:6" https://code.sololearn.com/W6a17A12a14A What could be the possible reason for this and what does this error mean? Ignore comments at the beginning. Added that because earlier sololearn was crashing on loading some codes and somebody told me to comments in the beginning of the code and it actually worked at that time. So, I was trying that but this time it doesn't and I need your assistance to understand the problem. Thanks a lot in advance!!

27th Jan 2021, 11:17 AM
CHANDAN ROY
CHANDAN ROY - avatar
1 Resposta
+ 8
//Add this window.onload = function() { your code } https://www.sololearn.com/post/90825/?ref=app
27th Jan 2021, 11:39 AM
Simba
Simba - avatar