why I'm getting this error in js console... in where other editor can play this without error.. but solorlearn is giving me erro | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

why I'm getting this error in js console... in where other editor can play this without error.. but solorlearn is giving me erro

JavaScript Console Uncaught TypeError: Cannot read property 'addEventListener' of null Line: 9Uncaught TypeError: Cannot read property 'style' of null Line: 12 link of my code is here: https://code.sololearn.com/W4CABL65B7ch/#js

20th Jun 2020, 5:55 AM
Moshiur Rahman Rony
Moshiur Rahman Rony - avatar
6 Answers
+ 3
add your js code in this function window.onload=function(){ all js code goes here } You can read about it on net, what it does and search for similar answers
20th Jun 2020, 6:33 AM
Abhay
Abhay - avatar
+ 3
Probably this helps ,it shows the support for different browser ,scroll to the bottom https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
21st Jun 2020, 8:52 AM
Abhay
Abhay - avatar
+ 2
probably that might be the reason
21st Jun 2020, 8:47 AM
Abhay
Abhay - avatar
0
Abhay thanks for your answer;;; but it doesn't work.. I am contually getting the error..
21st Jun 2020, 8:30 AM
Moshiur Rahman Rony
Moshiur Rahman Rony - avatar
0
well, that is the reason may be; The addEventListener() method is not supported in Internet Explorer 8 and earlier versions.
21st Jun 2020, 8:36 AM
Moshiur Rahman Rony
Moshiur Rahman Rony - avatar
0
Thanks bro.. I have looked it... but can't get anything of it... so much text for a simple explanation...
21st Jun 2020, 9:21 AM
Moshiur Rahman Rony
Moshiur Rahman Rony - avatar